3v4l.org

run code in 300+ PHP versions simultaneously
<?php $certidoes = array( array( 'id_certidao' => 1, 'checked' => 1 ), array( 'id_certidao' => 2, 'checked' => 0 ), array( 'id_certidao' => 3, 'checked' => 1 ) ); foreach ($certidoes as $certidao) { $checked = ""; if ($certidao['checked']) { $checked = "checked"; } echo '<input type="checkbox" id="check_'.$certidao['id_certidao'].'" name="check['.$certidao['id_certidao'].']" ' . $checked . ' value="1" />' . PHP_EOL; } //Dados para teste $_POST['check'] = array( 0 => 1, 1 => 3 ); $_POST['emissao'] = array( 1 => '10/10/2013', 2 => '11/10/2013', 3 => '12/10/2013' ); $_POST['validade'] = array( 1 => '10/10/2013', 2 => '10/11/2013', 3 => '10/12/2013' ); if (isset($_POST['check'])) { foreach ($_POST['check'] as $id) { $id_certidao = filter_var($id, FILTER_SANITIZE_NUMBER_INT); $emissao = filter_var($_POST['emissao'][$id_certidao], FILTER_SANITIZE_STRING); $validade = filter_var($_POST['validade'][$id_certidao], FILTER_SANITIZE_STRING); $insert = "INSERT INTO tb_certidao VALUES ( '$id_certidao', '$emissao', '$validade' )"; echo $insert.PHP_EOL; } }
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<input type="checkbox" id="check_1" name="check[1]" checked value="1" /> <input type="checkbox" id="check_2" name="check[2]" value="1" /> <input type="checkbox" id="check_3" name="check[3]" checked value="1" /> Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/Wps4A on line 47 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/Wps4A on line 48 INSERT INTO tb_certidao VALUES ( '1', '10/10/2013', '10/10/2013' ) Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/Wps4A on line 47 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/Wps4A on line 48 INSERT INTO tb_certidao VALUES ( '3', '12/10/2013', '10/12/2013' )
Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
<input type="checkbox" id="check_1" name="check[1]" checked value="1" /> <input type="checkbox" id="check_2" name="check[2]" value="1" /> <input type="checkbox" id="check_3" name="check[3]" checked value="1" /> INSERT INTO tb_certidao VALUES ( '1', '10/10/2013', '10/10/2013' ) INSERT INTO tb_certidao VALUES ( '3', '12/10/2013', '10/12/2013' )
Output for 5.0.2 - 5.0.5, 5.1.0 - 5.1.6
<input type="checkbox" id="check_1" name="check[1]" checked value="1" /> <input type="checkbox" id="check_2" name="check[2]" value="1" /> <input type="checkbox" id="check_3" name="check[3]" checked value="1" /> Fatal error: Call to undefined function filter_var() in /in/Wps4A on line 46
Process exited with code 255.
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Wps4A on line 23 <input type="checkbox" id="check_1" name="check[1]" checked value="1" />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Wps4A on line 23 <input type="checkbox" id="check_2" name="check[2]" value="1" />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Wps4A on line 23 <input type="checkbox" id="check_3" name="check[3]" checked value="1" />PHP_EOL Fatal error: Call to undefined function filter_var() in /in/Wps4A on line 46
Process exited with code 255.
Output for 4.4.5 - 4.4.9
<input type="checkbox" id="check_1" name="check[1]" checked value="1" /> <input type="checkbox" id="check_2" name="check[2]" value="1" /> <input type="checkbox" id="check_3" name="check[3]" checked value="1" /> Fatal error: Call to undefined function: filter_var() in /in/Wps4A on line 46
Process exited with code 255.
Output for 4.3.10 - 4.3.11, 4.4.0 - 4.4.4
<input type="checkbox" id="check_1" name="check[1]" checked value="1" /> <input type="checkbox" id="check_2" name="check[2]" value="1" /> <input type="checkbox" id="check_3" name="check[3]" checked value="1" /> Fatal error: Call to undefined function: filter_var() in /in/Wps4A on line 46
Process exited with code 255.
Output for 4.3.2 - 4.3.9
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Wps4A on line 23 <input type="checkbox" id="check_1" name="check[1]" checked value="1" />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Wps4A on line 23 <input type="checkbox" id="check_2" name="check[2]" value="1" />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Wps4A on line 23 <input type="checkbox" id="check_3" name="check[3]" checked value="1" />PHP_EOL Fatal error: Call to undefined function: filter_var() in /in/Wps4A on line 46
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Wps4A on line 23 <input type="checkbox" id="check_1" name="check[1]" checked value="1" />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Wps4A on line 23 <input type="checkbox" id="check_2" name="check[2]" value="1" />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Wps4A on line 23 <input type="checkbox" id="check_3" name="check[3]" checked value="1" />PHP_EOL Fatal error: Call to undefined function: filter_var() in /in/Wps4A on line 46

preferences:
238.3 ms | 402 KiB | 387 Q