aebstract Posted March 1, 2010 Share Posted March 1, 2010 I have a string, something basically like: $string = "a lot of text a lot of text a lot of text a lot of text a lot of text [[image.jpg]] a lot of text a lot of text a lot of text a lot of text [[image2.jpg]] a lot of text a lot of text a lot of text a lot of text [[image3.jpg]]"; I'm needing to grab the first [[*]] value in the string, remove it from the string and set it as a variable, $firstimage. Then I'll need to just delete all of the others from the string. Could someone help me with this, are there any real good resources for regex online? Thanks Link to comment https://forums.phpfreaks.com/topic/193777-help-with-regex/ Share on other sites More sharing options...
aeroswat Posted March 1, 2010 Share Posted March 1, 2010 Couldn't you use strpos with substr? Something like this $firstimage = substr($str,strpos('['),strpos('])); Link to comment https://forums.phpfreaks.com/topic/193777-help-with-regex/#findComment-1019922 Share on other sites More sharing options...
aebstract Posted March 1, 2010 Author Share Posted March 1, 2010 Ended up being a bit off of what you have, gonna be an equal pain in the ass to do the second part like this, but oh well. $firstimage = substr(substr($article, strpos($article, '['), strpos($article, ']')), 2); Link to comment https://forums.phpfreaks.com/topic/193777-help-with-regex/#findComment-1019977 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.