3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function slashit(&$aray, $db_link) { foreach ($aray as $key => &$value) if(is_array($value)) slashit($value, $link); else $aray[$key] = mysql_real_escape_string($value, $db_link); } // Test: $fruits = array ( "fruits" => array("a" => "or'ange", "b" => "ban'ana", "c" => "apple'"), "numbers" => array(1, 2, 3, 4, 5, 6), "holes" => array("fir'st", 5 => "sec'ond", "thir'd"), "odma" => "jugo'slavija" ); // You have to make link to the database or can use addslashes instead of mysql_real_escape_string and remove $link from function definition slashit($fruits, $dbLink); echo "<pre>"; print_r($fruits); echo "</pre>";
Output for 7.0.0 - 7.1.0
Notice: Undefined variable: dbLink in /in/4BeKi on line 20 Notice: Undefined variable: link in /in/4BeKi on line 6 Fatal error: Uncaught Error: Call to undefined function mysql_real_escape_string() in /in/4BeKi:7 Stack trace: #0 /in/4BeKi(6): slashit(Array, NULL) #1 /in/4BeKi(20): slashit(Array, NULL) #2 {main} thrown in /in/4BeKi on line 7
Process exited with code 255.
Output for 5.0.4 - 5.6.28
Notice: Undefined variable: dbLink in /in/4BeKi on line 20 Notice: Undefined variable: link in /in/4BeKi on line 6 Fatal error: Call to undefined function mysql_real_escape_string() in /in/4BeKi on line 7
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: dbLink in /in/4BeKi on line 20 Notice: Undefined variable: link in /in/4BeKi on line 6 Fatal error: Call to undefined function mysql_real_escape_string() in /in/4BeKi on line 7
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/4BeKi on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/4BeKi on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/4BeKi on line 5
Process exited with code 255.