"); # if its opening PHP, push on stack if($chars == "")) && (count($stack) > 0)) { $start = array_pop($stack); $startend[$index]["start"] = $start; $startend[$index]["end"] = $i + 2; # put internal array pointer back to end of array for correct stack operation end($startend); # increment pair array storage index $index++; } } # loop through all start/end pairs for($id=1; $id<=count($startend); $id++) { #$id = $i+1; $imageid = "PHPCODE{$id}"; $imgcode = ""; $this->imageArray[$id] = $imgcode; $sectionlength = ($startend[$id]["end"] - $startend[$id]["start"]); $this->codeArray[$id] = substr($code, $startend[$id]["start"], $sectionlength); $this->idArray[$id] = $imageid; #$code = substr_replace($code, $imgcode, $startend[$id]["start"], $sectionlength); } $code = str_replace($this->codeArray,$this->imageArray,$code); return $code; } # replaces placeholders by restoring relevant PHP code section function restore($code) { $newImageArray = array(); for($i=1; $i<=count($this->idArray); $i++) { $newImageArray[$i] = $this->returnImgString($this->idArray[$i], $code); } #print_r($newImageArray); # return "restored" code return str_replace($newImageArray, $this->codeArray, $code); } # finds complete image tag based on unique ID function returnImgString($idtag, $code) { $position=0; // Position of tag $pos_start=0; // Start Position $pos_finish=0; // End positon $str_start=""; // String Before image tag $str_finish=""; // String after image tag // Return null is input is blank. if(!isset($idtag) or $idtag==""){return "";} // Return null is code input is blank. if(!isset($code) or $code==""){return "";} // Find tag $position=strpos($code,$idtag); // Id tag has been removed; if($position==0){return "";} $str_start=strtolower(strrev(substr($code,0,$position))); $pos_start=strlen($str_start)- strpos($str_start,"gmi<") -4; //-4 is the length of the image tag $str_finish=strtolower(substr($code,$position)); $pos_finish=strpos($code,">",$pos_start)+1; return (substr($code,$pos_start,$pos_finish-$pos_start)); } } ?> Sonia Picado (Costa Rica)

Combating discrimination and promoting equality as a fundamental human right and a basic principle of social justice

Site designed and build by www.emosaic.co.uk