我在下面的代码中显示了圣保罗/巴西的所有邮政编码。 这里的事情是,它没有显示正确的数字,它显示的是完全不同的数字。
如何修复它以显示$SP
数组中的数字?
$SP = ['São Paulo 1' => [01000, 05999], 'São Paulo 2' => [08000, 08499], 'Osasco' => [06000, 06299], 'Carapicuiba' => [06300, 06399], 'Barueri' => [06400, 06499], 'Santana do Parnaíba' => [06500, 06549], 'Pirapora Do Bom Jesus' => [06550, 06599], 'Jandira' => [06600, 06649], 'Itapevi' => [06650, 06699], 'Cotia' => [06700, 06729], 'Vargem Grande Paulista' => [06730, 06749], 'Taboão Da Serra' => [06750, 06799], 'Embu' => [06800, 06849], 'Itapecerica Da Serra' => [06850, 06889], 'São Lourenço Da Serra' => [06890, 06899], 'Embu-Guaçu' => [06900, 06930], 'Juquitiba' => [06950, 06999], 'Guarulhos' => [07000, 07399], 'Arujá' => [07400, 07499], 'Santa Isabel' => [07500, 07599], 'Mairiporã' => [07600, 07699], 'Caieiras' => [07700, 07749], 'Cajamar' => [07750, 07769], 'Franco da Rocha' => [07800, 07899], 'Francisco Morato' => [07900, 07999], 'Ferraz de Vasconcelos' => [08500, 08549], 'Poá' => [08550, 08569], 'Itaquaquecetuba' => [08570, 08599], 'Suzano' => [08600, 08699], 'Mogi das Cruzes' => [08700, 08899], 'Guararema' => [08900, 08939], 'Biritiba-Mirim' => [08940, 08969], 'Salesópolis' => [08970, 08979], 'Santo,ndré' => [09000, 09299], 'Mauá' => [09300, 09399], 'Ribeirão Pires' => [09400, 09449], 'Rio Grande da Serra' => [09450, 09499], 'São Caetano do Sul' => [09500, 09599], 'São Bernardo do Campo' => [09600, 09899], 'Diadema' => [09900, 09999], 'SP Litoral' => [11000, 11999], 'SP Interior' => [12000, 19999]];
foreach ($SP as $key => $value) {
echo $key . ': ';
var_dump($value);
echo '<BR>';
}
结果:
São Paulo 1: array(2) { [0]=> int(512) [1]=> int(5) }
São Paulo 2: array(2) { [0]=> int(0) [1]=> int(0) }
Osasco: array(2) { [0]=> int(3072) [1]=> int(50) }
Carapicuiba: array(2) { [0]=> int(3264) [1]=> int(51) }
Barueri: array(2) { [0]=> int(3328) [1]=> int(52) }
...
答案 0 :(得分:1)
答案 1 :(得分:1)
以0开头的5位数长度数字不被视为十进制数。如果你想保持零,你必须使用引号:"01000"
答案 2 :(得分:1)