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($data, 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/qUQEB on line 37 Warning: iconv(): Wrong encoding, conversion from "ISO-8859-1" to "UTF-8" is not allowed in /in/qUQEB on line 43 Warning: iconv(): Wrong encoding, conversion from "ISO-8859-1" to "UTF-8" is not allowed in /in/qUQEB on line 43 Warning: iconv(): Wrong encoding, conversion from "ISO-8859-1" to "UTF-8" is not allowed in /in/qUQEB on line 43 array(2) { [0]=> string(5) "ASCII" [1]=> string(5) "UTF-8" } string(5) "ASCII" string(10) "ISO-8859-1" string(203) "{"tram B":[{"name":false,"distance":298,"stationID":762},{"name":false,"distance":425,"stationID":771}],"16":[{"name":false,"distance":531,"stationID":397},{"name":false,"distance":589,"stationID":438}]}"

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:
34.33 ms | 402 KiB | 8 Q