Hi
I have some description and Iframe value in my database fields . I want to display only Iframe value. Like this
<p>Description:</p>
<p>In this action packed multi level game, you've to help A.L.I.A.S to battle his way through the army base and blast all the enemies and obstacles with his high fire rate gun. Each kill restores a bit of health (power-ups help for that, too). At the end of the game, your score will be multiplied by the number corresponding to the chosen difficulty level...Good
[button link="http://graggles.com/help/" type="icon" icon="notice" newwindow="yes"] Game is not working? (Click here) [/button]
<iframe src="http://www.freeonlinegames.com/embed.php?g_id=924" width="550" height="350" scrolling="no" allowTransparency="true" frameborder="0"></iframe>
I want to take only
<iframe src="http://www.freeonlinegames.com/embed.php?g_id=924" width="550" height="350" scrolling="no" allowTransparency="true" frameborder="0"></iframe>
from above value.
How this can b possible in php.
thanks
Display only Iframe value
Moderator: General Moderators
-
shafiq2626
- Forum Commoner
- Posts: 88
- Joined: Wed Mar 04, 2009 1:54 am
- Location: Lahore
- Contact:
Re: Display only Iframe value
Hi,
you can use regular expressions in PHP with preg_match, this would look like that:
$matches[0] will return the whole <iframe>, and $matches[1] will return only the src part.
Greets.
you can use regular expressions in PHP with preg_match, this would look like that:
Code: Select all
$searchin = <<<EOF
<p>Description:</p>
<p>In this action packed multi level game, you've to help A.L.I.A.S to battle his way through the army base and blast all the enemies and obstacles with his high fire rate gun. Each kill restores a bit of health (power-ups help for that, too). At the end of the game, your score will be multiplied by the number corresponding to the chosen difficulty level...Good
[button link="http://graggles.com/help/" type="icon" icon="notice" newwindow="yes"] Game is not working? (Click here) [/button]
<iframe src="http://www.freeonlinegames.com/embed.php?g_id=924" width="550" height="350" scrolling="no" allowTransparency="true" frameborder="0"></iframe>
EOF;
preg_match("/\<iframe src=\"(.*)\" width.*\>\<\/iframe\>/", $searchin, $matches);
Greets.