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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -