php - Get information between two strings -


i have following php string

$string = "hello world<br>- 8/7/2013<br>hello world"; 

so basically, need information between dash , space (-) , closest line break tag. appreciated! looked hours haven't been successful. don't think preg_replace either.

strpos finds index of substring (optionally after specified index), so:

$start = strpos($string, '- ') + 2; $end   = strpos($string, '<br>', $start); $part  = substr($string, $start, $end - $start); 

ta-da!


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -