3v4l.org

run code in 300+ PHP versions simultaneously
<?php $mysql_result[0]['id']="1"; $mysql_result[1]['id']="2"; $mysql_result[2]['id']="3"; $mysql_result[0]['address']="www.example.com/page1"; $mysql_result[1]['address']="www.example.com/page2"; $mysql_result[2]['address']="www.example.com/page3"; $mysql_result[0]['title']="Page 1"; $mysql_result[1]['title']="Page 2"; $mysql_result[2]['title']="Page 3"; $mysql_result[0]['content']="The quick dog jumps over the lazy dog."; $mysql_result[1]['content']="The best thing about morning is breakfast."; $mysql_result[2]['content']="Hotdogs are great ballpark food."; $mysql_result[0]['image']="image1.jpg"; $mysql_result[1]['image']="image2.jpg"; $mysql_result[2]['image']="image3.jpg"; $query="dog"; $chars_to_show_before = 10; $chars_to_show_after = 10; foreach($mysql_result as $results) { $content = str_replace($query,"my_un1qu3_r3pl4c3m3nt_".$query,$results['content']); $occurences = explode("my_un1qu3_r3pl4c3m3nt_",$content); $position_in_original_content = 0; foreach($occurences as $an_occurence) { if (strpos($an_occurence,$query) !== false) { $content=$an_occurence; //echo "\npos $position_in_original_content\n"; //echo "\n\nworking on \n".substr($results['content'],$position_in_original_content-$chars_to_show_before,strlen(strlen($query))+$chars_to_show_after+$chars_to_show_before)."\n\n"; echo '<li class="media"> <a class="pull-left" href="'.$results['address'].'"> <img class="media-object thumbnail" src="'.$results['image'].'" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="'.$results['address'].'">'.$results['title'].'</a></h4> <p>...'.str_replace($query,'<strong>'.$query.'</strong>', substr($results['content'],max(0,($position_in_original_content-$chars_to_show_before)),strlen(strlen($query))+$chars_to_show_after+$chars_to_show_before)).'...</p> </div>'.($position_in_original_content-0).' and '.(strlen($an_occurence)+0).' </li>'; } $position_in_original_content = $position_in_original_content + strlen($an_occurence); } }
Output for git.master, git.master_jit, rfc.property-hooks
<li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="image1.jpg" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page1">Page 1</a></h4> <p>...The quick <strong>dog</strong> jumps o...</p> </div>10 and 24 </li><li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="image1.jpg" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page1">Page 1</a></h4> <p>... the lazy <strong>dog</strong>....</p> </div>34 and 4 </li><li class="media"> <a class="pull-left" href="www.example.com/page3"> <img class="media-object thumbnail" src="image3.jpg" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page3">Page 3</a></h4> <p>...Hot<strong>dog</strong>s are great bal...</p> </div>3 and 29 </li>

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:
66.71 ms | 404 KiB | 8 Q