3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $the_mysql_result = array(); $the_mysql_result[0]['id'] = "1"; $the_mysql_result[0]['address']="www.example.com/page1"; $the_mysql_result[0]['title']="Page 1"; $the_mysql_result[0]['content']="The quick dog jumps over the lazy dog."; $the_mysql_result[1]['id'] = "2"; $the_mysql_result[1]['address']="www.example.com/page2"; $the_mysql_result[1]['title']="Page 2"; $the_mysql_result[1]['content']="The best thing about morning is breakfast."; $the_mysql_result[2]['id'] = "3"; $the_mysql_result[2]['address']="www.example.com/page3"; $the_mysql_result[2]['title']="Page 3"; $the_mysql_result[2]['content']="Hotdogs are great ballpark food."; $query="dog"; foreach($the_mysql_result as $results) { $content = $results['content']; $row_occurences = explode($query,$content); foreach($row_occurences as $an_occurence) { $content=$an_occurence.$query; 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($content,strpos($content,$query)-25,160)).'...</p> </div> </li>'; $total++; } }
Output for 5.3.0 - 5.6.21, hhvm-3.12.0, 7.0.0 - 7.1.0
Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="" 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>...</p> </div> </li> Notice: Undefined variable: total in /in/tXhOv on line 43 Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page1">Page 1</a></h4> <p>... <strong>dog</strong>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page1">Page 1</a></h4> <p>....<strong>dog</strong>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page2"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page2">Page 2</a></h4> <p>...out morning is breakfast.<strong>dog</strong>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page3"> <img class="media-object thumbnail" src="" 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>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page3"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page3">Page 3</a></h4> <p>... are great ballpark food.<strong>dog</strong>...</p> </div> </li>
Output for hhvm-3.10.0
Notice: Undefined index: image in /in/tXhOv on line -1 <li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="" 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>...</p> </div> </li> Notice: Undefined variable: total in /in/tXhOv on line -1 Notice: Undefined index: image in /in/tXhOv on line -1 <li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page1">Page 1</a></h4> <p>... <strong>dog</strong>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line -1 <li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page1">Page 1</a></h4> <p>....<strong>dog</strong>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line -1 <li class="media"> <a class="pull-left" href="www.example.com/page2"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page2">Page 2</a></h4> <p>...out morning is breakfast.<strong>dog</strong>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line -1 <li class="media"> <a class="pull-left" href="www.example.com/page3"> <img class="media-object thumbnail" src="" 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>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line -1 <li class="media"> <a class="pull-left" href="www.example.com/page3"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page3">Page 3</a></h4> <p>... are great ballpark food.<strong>dog</strong>...</p> </div> </li>
Output for 5.0.4 - 5.2.1, 5.2.7 - 5.2.17
Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="" 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>...</p> </div> </li> Notice: Undefined variable: total in /in/tXhOv on line 43 Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page1">Page 1</a></h4> <p>... <strong>dog</strong>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page1">Page 1</a></h4> <p>....<strong>dog</strong>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page2"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page2">Page 2</a></h4> <p>...out morning is breakfast.<strong>dog</strong>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page3"> <img class="media-object thumbnail" src="" 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>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page3"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page3">Page 3</a></h4> <p>... are great ballpark food.<strong>dog</strong>...</p> </div> </li>
Output for 5.2.2 - 5.2.6
Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page1">Page 1</a></h4> <p>......</p> </div> </li> Notice: Undefined variable: total in /in/tXhOv on line 43 Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page1">Page 1</a></h4> <p>... <strong>dog</strong>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page1">Page 1</a></h4> <p>......</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page2"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page2">Page 2</a></h4> <p>...out morning is breakfast.<strong>dog</strong>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page3"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page3">Page 3</a></h4> <p>......</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page3"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page3">Page 3</a></h4> <p>... are great ballpark food.<strong>dog</strong>...</p> </div> </li>
Output for 4.3.0 - 5.0.3
Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="" 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>...</p> </div> </li> Notice: Undefined variable: total in /in/tXhOv on line 43 Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page1">Page 1</a></h4> <p>... <strong>dog</strong>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page1"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page1">Page 1</a></h4> <p>....<strong>dog</strong>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page2"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page2">Page 2</a></h4> <p>...out morning is breakfast.<strong>dog</strong>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page3"> <img class="media-object thumbnail" src="" 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>...</p> </div> </li> Notice: Undefined index: image in /in/tXhOv on line 36 <li class="media"> <a class="pull-left" href="www.example.com/page3"> <img class="media-object thumbnail" src="" style="height:100px !important"> </a> <div class="media-body"> <h4 class="media-heading"><a href="www.example.com/page3">Page 3</a></h4> <p>... are great ballpark food.<strong>dog</strong>...</p> </div> </li>