Originally posted by superwormy
Why are there all those underscores in teh function call?
And post the exact error message please... and the line it occured on...
ahhh the damn came from copying so I had to clean it up, couldnt see the ... anyways here is what I have:
<?
$contents = 'Tesing image placement, this is the start of image one: <start img><hp_main><alt name here><12><6><1><center><end img>
<P>This is image two:<start img><hp_08><alt name here><40><12><3><center><end img>
<P>more code.';
?>
<hr>
<?
// $contents is the whole string
// $starttag would be <h3>
// $endtag would be </h3>
// $number should be the number of strings you want returned, it if you just want the first instance of <h3>text</h3> set it to 1, if you wanted to find the second instance too, set it to two, etc.
// returns an array of matches
function Get_String_Between_Strings ($contents, $starttag="<start img>", $endtag="<end img>", $number = FALSE ) {
$matches=array();
$starttag_length = strlen ($starttag );
if(strstr($contents,$starttag)){
while(strstr($contents,$endtag)){
$contents=strstr($contents,$starttag);
$contents=substr($contents,$starttag_length);
$tostrip=strstr($contents,$endtag);
$matches[]=str_replace($tostrip,"",$contents);
}
}
if($number){
$slice=array_slice($matches,0,$number);
return_($slice);
} else {
return ($matches);
}
}
?>
now what am I echoing not sure how to call it out... sorry if I am being stupid I fairly new at this stuff.