Page 1 of 1

Get Before Character

Posted: Tue Jul 02, 2013 2:31 pm
by FrederickGeek8
I'm trying to parse bbcode and there is this special img tag that allows width and height and comes in this format:
[img=500x300][/img]
How can I take 500x300 and split the string into 500 and 300? (two separate string)

Right now I have this but the number 500 and 300 for some reason are not included in the output string.
"<img style='height:".strstr("$1", 'x', true).";width:".strstr("$1", 'x').";' src=\"$2\" />"
preg_split also doesn't work. The first index of the array just contains the full string

Re: Get Before Character

Posted: Wed Jul 24, 2013 8:23 pm
by Temor
the first thing that comes to mind would be to explode on x and remove the first 5 letters of the first index ( [img= ) and the last character in the second index ( ] ). But that might not work with what you have set up.