-2

I have a URL in my iFrame:

<iframe src="http://example.com/video/123/"></iframe>.

In PHP, how do I edit this to add ?wmode=transparent to the end of the URL.

Thank you

michaelmcgurk
  • 6,367
  • 23
  • 94
  • 190
  • 1
    Explain "how do I edit this" ? Give us some background context please? – Gabriel Nov 24 '14 at 14:10
  • You need to take pre-made html with that iframe tag and modify it? Then use [DOM](http://php.net/dom). Otherwise, if you're building that iframe to start with, then just put that extra bit in. – Marc B Nov 24 '14 at 14:10
  • With php you can't edit existing html. What you can do is have different case statements to print the write code. – wayzz Nov 24 '14 at 14:11
  • 1
    Well if that HTML code is generated through PHP just find where and add whatever you want. If not, then use Javascript instead. – Laurent S. Nov 24 '14 at 14:11
  • An excellent point, @Gabriel, I need this code to work so IF it's an iframe, it will add this portion of code. – michaelmcgurk Nov 24 '14 at 14:14
  • So my code could be `$string = "

    test

    test

    ";` - how do I append `?wmode=transparent` to the end of the URL?
    – michaelmcgurk Nov 24 '14 at 14:15
  • Basically right now, I have no control over the HTML outputted, I need to add this `?wmode=transparent` in afterwards. – michaelmcgurk Nov 24 '14 at 14:16

2 Answers2

0

You could just echo the string in the url.

<iframe src="http://example.com/video/123/<?php echo "?wmode=transparent" ?>></iframe>

Grice
  • 1,345
  • 11
  • 24
0

Let's say you've got a php page that will print the following html:

<iframe src="http://example.com/video/123/"></iframe>

With php you can do a lot of things, as example:

<?php
$myVarToAppend = "?wmode=transparent"; //Putting the val inside a variable.
?>

<iframe src="http://example.com/video/123/<?php print $myVarToAppend; ?>"></iframe>

The var can be populated with a lot of things like DataBase Response or what you want. That said if you need to do this on runtime (without page reload) you need to do it with Javascript

Edit: I've choose to not print all the String because it's better to use php only when needed, no gain in printing everything with it.

Edit2: After your comment, you've said you've got two String:

Attention, your string written as below don't work well, the " are putted wrongly.

$string = "<p>test</p><iframe src="http://example.com/video/123/"></iframe><p>test</p>";

and

$toAdd = "?wmode=transparent";

you can do it this way: I use . for concatenation of strings.

$string = '<p>test</p><iframe src="http://example.com/video/123/'.$toAdd.'"></iframe><p>test</p>';

There are maybe other ways too, but with so little information is the maximum i can do for now.

Marco Mura
  • 582
  • 2
  • 13