3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $pagetext = 'Here\'s some text and stuff what is your favorite color? @OTHER["favorite color"] Whats your favorite food? @OTHER["favorite food"]'; $c = 0; while(strpos($pagetext, "@OTHER[") !== false){ $start = strpos($pagetext, '@OTHER["') + 8; $stop = strpos($pagetext, '"]', $start); $label = substr($pagetext, $start, $stop-$start); $pagetext = str_replace('@OTHER["'.$label.'"]','<input type="text" name="otherlabel'.$c.'" value="'.$label.'" /><input type="text" name="otherfield'.$c.'"><br /><small><i>'.$label.'</i></small>',$pagetext); $c++; } echo $pagetext;
based on hPl8e
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Here's some text and stuff what is your favorite color? <input type="text" name="otherlabel0" value="favorite color" /><input type="text" name="otherfield0"><br /><small><i>favorite color</i></small> Whats your favorite food? <input type="text" name="otherlabel1" value="favorite food" /><input type="text" name="otherfield1"><br /><small><i>favorite food</i></small>
Output for hhvm-3.10.0

Process exited with code 153.