3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); $data = array ( 'tram B' => array ( 0 => array ( 'name' => 'Ile Verte' , 'distance' => 298, 'stationID' => 762, ), 1 => array ( 'name' => 'La Tronche Hôpital' , 'distance' => 425, 'stationID' => 771, ), ), 16 => array ( 0 => array ( 'name' => 'Bastille', 'distance' => 531, 'stationID' => 397 ), 1 => array ( 'name' => 'Xavier Jouvin', 'distance' => 589, 'stationID' => 438, ), ), ); $data['tram B'][1]['name'] = iconv('UTF8', 'ISO-8859-1', $data['tram B'][1]['name']); $fromEncoding = 'ISO-8859-1'; // This depends on the data array_walk_recursive($array, function (&$value, $key, $fromEncoding) { if (is_string($value)) { $value = iconv($fromEncoding, 'UTF-8', $value); } }, $fromEncoding); var_dump( mb_detect_order(), mb_detect_encoding($data['tram B'][1]['name']), mb_detect_encoding($data['tram B'][1]['name'], array('ISO-8859-1', 'UTF-8')), json_encode($data) );
Output for git.master, git.master_jit, rfc.property-hooks
Warning: iconv(): Wrong encoding, conversion from "UTF8" to "ISO-8859-1" is not allowed in /in/TS4uI on line 37 Fatal error: Uncaught TypeError: array_walk_recursive(): Argument #1 ($array) must be of type array, null given in /in/TS4uI:41 Stack trace: #0 /in/TS4uI(41): array_walk_recursive(NULL, Object(Closure), 'ISO-8859-1') #1 {main} thrown in /in/TS4uI on line 41
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.19 ms | 401 KiB | 8 Q