3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $datetoday = date('dmy'); $row_Num = '1'; $i = 0; $count = 0; // I added this line to take care of how many times the loop runs foreach ($_REQUEST as $key => $value) { (strstr($key, 'date')) ? $count++ : NULL; } // Changed '<=' to '<' since it would loop 3 times since we start $i at 0 while ($i < $count) { ${'date_' . $i} = $_REQUEST["date_$i"]; ${'text_' . $i} = $_REQUEST["text_$i"]; ${'con_name_' . $i} = $_REQUEST["con_name_$i"]; ${'con_phone_' . $i} = $_REQUEST["con_phone_$i"]; $values = array( ${"date_" . $i}, ${"text_" . $i}, ${"con_name_" . $i}, ${"con_phone_" . $i} ); echo '<pre>', print_r($values, true), '</pre>'; $sql = "INSERT INTO `data`.`".$datetoday."` (`KEY`,`DATE`,`COLOR`,`TEXT`,`CON_NAME`,`PHONE`) VALUES ( '".$i."', '".$values[0]."', 'FFFFFF', '".$values[1]."', '".$values[2]."', '".$values[3]."' )"; echo '<pre>', $sql, '</pre>'; //$result = mysql_query($sql, $link) or die ('Could not insert values: '.mysql_error()); $i++; }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0