3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function escape_quote($data) { $clean = array(); foreach ($data as $key=>$val) { if (is_array($val)) { escape_quote($val); } $val = str_replace("'", "''", $val); $clean[$key] = $val; } return $clean; } $vars = array ( 'customer1' => array ( 'fname' => 'John', 'lname' => "D'oe" ), 'customer2' => array ( 'name' => array ( 'fname' => 'John', 'lname' => "D'oe" ), 'address' => '1234 street', 'phone' => '1234567899' ) ); $output = escape_quote($vars); print_r($output);
Output for 4.3.2 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [customer1] => Array ( [fname] => John [lname] => D''oe ) [customer2] => Array ( [name] => Array ( [fname] => John [lname] => D'oe ) [address] => 1234 street [phone] => 1234567899 ) )
Output for 4.3.0 - 4.3.1
Notice: Array to string conversion in /in/8lQLJ on line 14 Array ( [customer1] => Array ( [fname] => John [lname] => D''oe ) [customer2] => Array ( [name] => Array [address] => 1234 street [phone] => 1234567899 ) )