Ask about a PHP problem here.
FrederickGeek8
Posts: 148 Joined: Wed Nov 30, 2011 10:31 pm
Post
by FrederickGeek8 » Tue Jul 02, 2013 2:31 pm
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
Temor
Posts: 1186 Joined: Thu May 05, 2011 8:04 pm
Post
by Temor » Wed Jul 24, 2013 8:23 pm
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.