How to insert html code inside an array in PHP?
I tried searching on internet but found nothing.
$html = array
('<IFRAME src="http://link1.com" width="1" height="1"
scrolling="auto" frameborder="0"></IFRAME>' ,
'<IFRAME src="http://link2.com" width="1" height="1"
scrolling="auto" frameborder="0"></IFRAME>' ,
'<IFRAME src="http://link3.com" width="1" height="1"
scrolling="auto" frameborder="0"></IFRAME>');
print_r ($html);
When I tried to print_r, there was no result.
There is no result because you are giving the output to the browser, which happily places three
<iframe>s with invalid source URLs in your page. So you see nothing for the same reason you would see nothing if you didprint '<p></p>';.If you view the page source you will see your HTML is there.
Normally to see HTML markup as “plain text” you would need to pass it through
htmlspecialchars— however, that function works with strings and here you have an array. So if you want to print the contents as human-readable text, you need to do something fancier and usearray_map: