3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $permalink = 'permalink'; $text_link = 'text_link'; $links = array( '<li><a>total</a></li>', '<li><a href="permalink">permalink</a></li>', '<li><a href="permalink">permalink</a></li>', ); $total = count($links); for($permalink=0; $permalink<=$total ;$permalink++){ $new_links[] = preg_replace('|<a>'.$total.'</a>|', '<a>'.$text_link.'</a>', $links[$permalink]); } print_r($new_links);
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined offset: 3 in /in/khtgS on line 13 Array ( [0] => <li><a>total</a></li> [1] => <li><a href="permalink">permalink</a></li> [2] => <li><a href="permalink">permalink</a></li> [3] => )
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined index: 3 in /in/khtgS on line 13 Array ( [0] => <li><a>total</a></li> [1] => <li><a href="permalink">permalink</a></li> [2] => <li><a href="permalink">permalink</a></li> [3] => )
Output for 4.3.0 - 5.2.17
Notice: Undefined offset: 3 in /in/khtgS on line 13 Array ( [0] => <li><a>total</a></li> [1] => <li><a href="permalink">permalink</a></li> [2] => <li><a href="permalink">permalink</a></li> [3] => )