Archives
Ftp_put() php function with example.
function mbmCountImg($txt = ”){ preg_match_all(‘/<img[^>]+>/i’,$txt, $result); //select img tags $img = array(); foreach( $result as $kk=>$v) { foreach( $result[$kk] as $k=>$vv) { preg_match_all(‘/(alt|title|src)=(“[^"]*”)/i’,$vv, $img[$k]); //images into arrays } } return count($img); //counting total arrays } Usage: $content .= ”; $content .= ”; $content .= ”; $content .= ”; echo mbmCountImg($content);
I use this function to determine duration of a FLV file. It works pretty cool. function mbmGetFLVDuration($file){ // read file if (file_exists($file)){ $handle = fopen($file, “r”); $contents = fread($handle, filesize($file)); fclose($handle); if (strlen($contents) > 3){ if (substr($contents,0,3) == “FLV”){ $taglen = hexdec(bin2hex(substr($contents,strlen($contents)-3))); if (strlen($contents) > $taglen){ $duration = hexdec(bin2hex(substr($contents,strlen($contents)-$taglen,3))); return $duration; } } } } [...]
// paging function v2 function mbmNextPrev($url=NULL,$num_rows=0,$start=0,$per_page=10){ $total_pages = ceil($num_rows/$per_page); $current_page = (($start/$per_page)+1); $tmp_cccccc = 5; // how many page numbers will be printed if(($current_page-$tmp_cccccc)>0){ $i_start = $current_page – $tmp_cccccc; }else{ $i_start = 1; } if(($current_page+$tmp_cccccc)<$total_pages){ $end = $current_page + $tmp_cccccc; }else{ $end = $total_pages; } if($current_page!=1){ $buf .= ”; $buf .= ”; $buf .= $lang['main']['paging_prev'].’ [...]