cyfer65 Posted October 5, 2009 Share Posted October 5, 2009 Is there any universal PHP function to get the string between 2 specified markers in a string..??<<<$RandomText>>>like say I wanted to always get the $RandomText that was between "<<<" and ">>>" is there any PHP function to do this..??like StringBetween($Var, $Start, $End) Link to comment Share on other sites More sharing options...
Synook Posted October 5, 2009 Share Posted October 5, 2009 You could use regular expressions: preg_match_all("/<<<(.*?)>>>/", $string, $matches);print_r($matches); Link to comment Share on other sites More sharing options...
jexus Posted October 5, 2009 Share Posted October 5, 2009 <?phpfunction stringBetween($var, $start, $end) { return preg_match('{' . preg_quote($start) . '(.*?)' . preg_quote($end) . '}s', $var, $m) ? $m[1] : '';} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.