<?php
$file = '{
"unidades": [
{
"bairro": "Ouro",
"cidade": "São Mateus do Sul",
"complemento": "" "",
"endereco": "Rua XYZ ABADA, 26",
"estado": "PR"
},
{
"bairro": "Centro",
"cidade": "Xinguara",
"complemento": ""TESTE TESTE TESTE"",
"endereco": "Rua ABC, 60",
"estado": "PA"
},
{
"bairro": "Prata",
"cidade": "Wenceslau Braz",
"complemento": "" ZENFORM "",
"endereco": "Rua HUEHUEHUE, 99",
"estado": "PR"
}
]
}';
foreach($lendo->unidades as $campo){
$ordenada[$campo->estado][] = $campo;
}
PD9waHAKJGZpbGUgPSAnewogICAgInVuaWRhZGVzIjogWwogICAgICAgIHsKICAgICAgICAgICAgImJhaXJybyI6ICJPdXJvIiwKICAgICAgICAgICAgImNpZGFkZSI6ICJTw6NvIE1hdGV1cyBkbyBTdWwiLAogICAgICAgICAgICAiY29tcGxlbWVudG8iOiAiJnF1b3Q7ICZxdW90OyIsCiAgICAgICAgICAgICJlbmRlcmVjbyI6ICJSdWEgWFlaIEFCQURBLCAyNiIsCiAgICAgICAgICAgICJlc3RhZG8iOiAiUFIiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICAgICJiYWlycm8iOiAiQ2VudHJvIiwKICAgICAgICAgICAgImNpZGFkZSI6ICJYaW5ndWFyYSIsCiAgICAgICAgICAgICJjb21wbGVtZW50byI6ICImcXVvdDtURVNURSBURVNURSBURVNURSZxdW90OyIsCiAgICAgICAgICAgICJlbmRlcmVjbyI6ICJSdWEgQUJDLCA2MCIsCiAgICAgICAgICAgICJlc3RhZG8iOiAiUEEiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICAgICJiYWlycm8iOiAiUHJhdGEiLAogICAgICAgICAgICAiY2lkYWRlIjogIldlbmNlc2xhdSBCcmF6IiwKICAgICAgICAgICAgImNvbXBsZW1lbnRvIjogIiZxdW90OyBaRU5GT1JNICZxdW90OyIsCiAgICAgICAgICAgICJlbmRlcmVjbyI6ICJSdWEgIEhVRUhVRUhVRSwgOTkiLAogICAgICAgICAgICAiZXN0YWRvIjogIlBSIgogICAgICAgIH0KICAgIF0KfSc7CgokbGVuZG8gPSBqc29uX2RlY29kZSgkZmlsZSk7CiRvcmRlbmFkYSA9IGFycmF5KCk7CmZvcmVhY2goJGxlbmRvLT51bmlkYWRlcyBhcyAkY2FtcG8pewogICAgJG9yZGVuYWRhWyRjYW1wby0+ZXN0YWRvXVtdID0gJGNhbXBvOwp9Cgp2YXJfZHVtcCgkb3JkZW5hZGEpOw==