3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $users = array("user1", "user2", "user3", "user4"); $usersInGroup = array("user1", "user3"); foreach($users as $user) { printf('<p>%s<input type="checkbox" %s /></p>', $user, in_array($user, $usersInGroup) ? 'checked' : ''); }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
<p>user1<input type="checkbox" checked /></p><p>user2<input type="checkbox" /></p><p>user3<input type="checkbox" checked /></p><p>user4<input type="checkbox" /></p>