php search function using wildcards

quanie

New Member
This question is nearly identicle to : http://stackoverflow.com/questions/2305362/php-search-string-with-wildcards, but will be arranged a little differently. I had a hard time understanding the proposed solutions to make my own out of them . Maybe you guys can help?I have a start string and an end string which I use to sandwich strings of interest. This is the function I'm currently using for this:\[code\]function get_string_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len);}\[/code\]Sometimes my beginning strings need to have wildcards in them to account for a dynamic part of a templatefor example I would need this to be my begin code variable:\[code\]$begin_code = "id='%wildcard%' class='sailors_assistant_%wildcard%'>";\[/code\]and edit my original function above to detect %wildcard%(s) and account for them when using their sandwich search-n-grabs. Any advise?
 
Back
Top