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=1; $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 - 7.1.0
Notice: Undefined offset: 3 in /in/j19H9 on line 13 Array ( [0] => <li><a href="permalink">permalink</a></li> [1] => <li><a href="permalink">permalink</a></li> [2] => )
Output for 4.3.0 - 5.2.17
Notice: Undefined offset: 3 in /in/j19H9 on line 13 Array ( [0] => <li><a href="permalink">permalink</a></li> [1] => <li><a href="permalink">permalink</a></li> [2] => )