Mistři v programování na #hovnokod

PHP #1089

Najít v textu obrázek, upravit mu šířku a výšku, zarovnat doprava a opravit HTML kód na XHTML? Hračka!

function find_image($strPage,$w,$h){
	$str="<img";
	$initial_pos = strpos($strPage, $str);
	if($initial_pos!="")
	{
	$final_pos=strpos($strPage,">",$initial_pos)-1;
	$length=$final_pos-$initial_pos;
	$return_str=substr($strPage,$initial_pos,$length)." />";
	$initial_pos=strpos($return_str,"width=")+7;
	$final_pos=strpos($return_str," ",$initial_pos)-1;
	$length=$final_pos-$initial_pos;
	$width=substr($return_str,$initial_pos,$length);
	//echo $width."- ".$initial_pos." ".$final_pos;
	$return_str=str_replace($width,$w,$return_str);
	$initial_pos=strpos($return_str,"height=")+8;
	$final_pos=strpos($return_str," ",$initial_pos)-1;
	$length=$final_pos-$initial_pos;
	$height=substr($return_str,$initial_pos,$length);
	//echo $width."- ".$initial_pos." ".$final_pos;
	$return_str=str_replace($height,$h,$return_str);
	$return_str=str_replace("left","right",$return_str);
	echo $return_str;
	}
	else
	echo "";
}

Anonymous,