3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $data = [ "shenzhen" => [ "宝安区", "南山区", "福田区", "罗湖区", "盐田区", "龙岗区", "光明新区", "坪山新区", "龙华新区", "大鹏新区", "其它" ], "guangzhou" => [ "白云区", "天河区", "海珠区", "番禺区", "花都区", "黄埔区", "南沙区", "越秀区", "萝岗区", "荔湾区", "增城市", "从化市", "其它" ]]; $city_list = array( "shenzhen" => _("深圳"), "guangzhou" => _("广州"), "foshan" => _("佛山"), "dongguan" => _("东莞")); $newArray = array(); foreach($city_list as $carr) { $newArray[] = str_replace(key($carr),"hello", $data); } print_r($newArray);
based on WlMDS
Output for 5.4.0 - 7.2.0
Warning: key() expects parameter 1 to be array, string given in /in/XVoqh on line 40 Warning: key() expects parameter 1 to be array, string given in /in/XVoqh on line 40 Warning: key() expects parameter 1 to be array, string given in /in/XVoqh on line 40 Warning: key() expects parameter 1 to be array, string given in /in/XVoqh on line 40 Array ( [0] => Array ( [shenzhen] => Array ( [0] => 宝安区 [1] => 南山区 [2] => 福田区 [3] => 罗湖区 [4] => 盐田区 [5] => 龙岗区 [6] => 光明新区 [7] => 坪山新区 [8] => 龙华新区 [9] => 大鹏新区 [10] => 其它 ) [guangzhou] => Array ( [0] => 白云区 [1] => 天河区 [2] => 海珠区 [3] => 番禺区 [4] => 花都区 [5] => 黄埔区 [6] => 南沙区 [7] => 越秀区 [8] => 萝岗区 [9] => 荔湾区 [10] => 增城市 [11] => 从化市 [12] => 其它 ) ) [1] => Array ( [shenzhen] => Array ( [0] => 宝安区 [1] => 南山区 [2] => 福田区 [3] => 罗湖区 [4] => 盐田区 [5] => 龙岗区 [6] => 光明新区 [7] => 坪山新区 [8] => 龙华新区 [9] => 大鹏新区 [10] => 其它 ) [guangzhou] => Array ( [0] => 白云区 [1] => 天河区 [2] => 海珠区 [3] => 番禺区 [4] => 花都区 [5] => 黄埔区 [6] => 南沙区 [7] => 越秀区 [8] => 萝岗区 [9] => 荔湾区 [10] => 增城市 [11] => 从化市 [12] => 其它 ) ) [2] => Array ( [shenzhen] => Array ( [0] => 宝安区 [1] => 南山区 [2] => 福田区 [3] => 罗湖区 [4] => 盐田区 [5] => 龙岗区 [6] => 光明新区 [7] => 坪山新区 [8] => 龙华新区 [9] => 大鹏新区 [10] => 其它 ) [guangzhou] => Array ( [0] => 白云区 [1] => 天河区 [2] => 海珠区 [3] => 番禺区 [4] => 花都区 [5] => 黄埔区 [6] => 南沙区 [7] => 越秀区 [8] => 萝岗区 [9] => 荔湾区 [10] => 增城市 [11] => 从化市 [12] => 其它 ) ) [3] => Array ( [shenzhen] => Array ( [0] => 宝安区 [1] => 南山区 [2] => 福田区 [3] => 罗湖区 [4] => 盐田区 [5] => 龙岗区 [6] => 光明新区 [7] => 坪山新区 [8] => 龙华新区 [9] => 大鹏新区 [10] => 其它 ) [guangzhou] => Array ( [0] => 白云区 [1] => 天河区 [2] => 海珠区 [3] => 番禺区 [4] => 花都区 [5] => 黄埔区 [6] => 南沙区 [7] => 越秀区 [8] => 萝岗区 [9] => 荔湾区 [10] => 增城市 [11] => 从化市 [12] => 其它 ) ) )
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/XVoqh on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/XVoqh on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/XVoqh on line 2
Process exited with code 255.