papaface Posted July 27, 2009 Share Posted July 27, 2009 Hello, I am trying to find the value of the text between square brackets in my string $str = "hell my name is [andrew]"; $find = preg_split("\[(*])\]", $str, null, 1); $name = trim($find[1]); However this is not working :'( Anyone got any ideas? Link to comment https://forums.phpfreaks.com/topic/167684-solved-find-value-between-square-brackets/ Share on other sites More sharing options...
ldougherty Posted July 28, 2009 Share Posted July 28, 2009 Hope this works out for you; took me a long time to figure that one out.. $str = "hell my name is [andrew]"; $keywords = preg_split("/[\[\]]/", $str); print_r($keywords); Link to comment https://forums.phpfreaks.com/topic/167684-solved-find-value-between-square-brackets/#findComment-884454 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.