3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input= "<p>text text text</p> <p>text text text</p> <p>text text text</p> <p>text text text</p> <p>text text text</p> <p>text text text</p>"; $arr =explode(PHP_EOL, $input); $adsbeforeparagraph = array(0,2,4); // subtracted 1 to suit normal array numbering $ad = 'ADS CODE'; Foreach($arr as $key => $line){ If(in_array($key, $adsbeforeparagraph)){ // is this a line that should have Ads? Echo $ad . $line . "\n"; }else{ Echo $line . "\n"; } }
Output for git.master, git.master_jit, rfc.property-hooks
ADS CODE<p>text text text</p> <p>text text text</p> ADS CODE<p>text text text</p> <p>text text text</p> ADS CODE<p>text text text</p> <p>text text text</p>

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
91.25 ms | 405 KiB | 5 Q