3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $my_array = array(); $my_array['id'] = 4127 ; $my_array['nick'] = 'Jonas'; $my_array['dte79855545'] = 5; $my_array['dte79855545'] = 5; $my_array['dte1111'] = 1; $my_array['dte2222'] = 2; $my_array['dte3333'] = 3; $my_array['dte4444'] = 4; $my_array_of_dte = array(); $dte_inc = 0; foreach($my_array as $key => $value) { if (substr($key,0,3)=='dte') { $my_array_of_dte[$dte_inc]['id'] = substr($key,3); $my_array_of_dte[$dte_inc]['value'] = $value; $dte_inc++; } } for($inc=0;$inc<$dte_inc;$inc++) { $query = "INSERT INTO user_count (id, nick, dte, count) VALUES ('".$value['id']."', '".$value['nick']."', '".$my_array_of_dte[$inc]['id']."', '".$my_array_of_dte[$inc]['value']."')"; // $result = mysql_query($query); echo $query."\n"; } ?>
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
INSERT INTO user_count (id, nick, dte, count) VALUES ('', '', '79855545', '5') INSERT INTO user_count (id, nick, dte, count) VALUES ('', '', '1111', '1') INSERT INTO user_count (id, nick, dte, count) VALUES ('', '', '2222', '2') INSERT INTO user_count (id, nick, dte, count) VALUES ('', '', '3333', '3') INSERT INTO user_count (id, nick, dte, count) VALUES ('', '', '4444', '4')