Shaun Posted December 11, 2007 Share Posted December 11, 2007 Hi everyone been a long time since ive been around here. anyhow I need a little help with something. suppose I have a variable $var = "-this is my var-"; how would i extract the text that is in between the "-" characters.. I am aware that I would need to use strpos() & strrpos() to do this but im really getting confused on how to actually do it. Any help would be most appreciated. Thank you! Shaun Link to comment https://forums.phpfreaks.com/topic/81107-solved-php-stringtext-manipulation-extract-text-that-is-within-certain-characters/ Share on other sites More sharing options...
trq Posted December 11, 2007 Share Posted December 11, 2007 <?php $var = "-this is my var-"; if (preg_match('/-(.*?)-/',$var,$m)) { echo $m[1]; } ?> Link to comment https://forums.phpfreaks.com/topic/81107-solved-php-stringtext-manipulation-extract-text-that-is-within-certain-characters/#findComment-411551 Share on other sites More sharing options...
Shaun Posted December 11, 2007 Author Share Posted December 11, 2007 I COULD KISS YOU! thank you very much! Link to comment https://forums.phpfreaks.com/topic/81107-solved-php-stringtext-manipulation-extract-text-that-is-within-certain-characters/#findComment-411557 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.