【发布时间】:2019-11-24 07:28:05
【问题描述】:
返回 mi Laravel 请求我得到了他的答案:
{
"_method": "POST",
"_token": null,
"nome": "AUTO ESCOLA GUILHERMITTI & LOBANCO LTDA",
"cnpj": "00635344000177",
"novoSegmento": null,
"natureza": "206-2",
"total": "49993",
"socio-0": "ELIANA CRISTINA GUILHERMITTI RODRIGUES 49-Sócio-Administrador",
"socio-1": "SUZANA MARQUES LOBANCO 49-Sócio-Administrador",
"socio-2": "AMARILDO APARECIDO RODRIGUES 49-Sócio-Administrador",
"socio-3": "VALDEMIR FRANCISCO DA COSTA 22-Sócio",
"socio-4": "ANDRE LUIS LOBANCO 49-Sócio-Administrador",
"nomeFantasia": null,
"IE": null,
"logradouro": null,
"numero": "1408",
"complemento": null,
"bairro": null,
"uf": "SP",
"cidade": "Bady Bassitt",
"ddd": null,
"telefone": null,
"ddd1": null,
"celular": null,
"receita1": "0.00",
"referenciaClientes": [
{
"nome": null
},
{
"ddd": null
},
{
"telefone": null
},
{
"ramal": null
},
{
"endereco": null
},
{
"bairro": null
},
{
"uf": null
},
{
"cidade": null
},
{
"cep": null
},
{
"email": null
}
],
"BancoreferenciaClientes": [
{
"contato": null
}
],
"referenciaCLientes": [
{
"complento": null
}
],
"banco": null,
"agencia": null,
"contaCorrente": null,
"bancoContato": null,
"telefoneBanco": null,
"cidadeBanco": null,
"imoveis": [
{
"enderecoBem": null
},
{
"areaBem": null
},
{
"valorBem": "0.00"
},
{
"cidadeBem": null
}
],
"aceite": "1"
}
我需要保存所有项目,但不知道如何正确处理socio-*。它是可变的,我永远不会知道它会发生多少次。
我对如何处理这个问题有点迷茫...... 我想我应该得到多少次 'socio' 使用:
$s = substr_count($request, 'socio');
现在我必须将它保存为 json,例如:
socio-0{
nome: "ELIANA CRISTINA GUILHERMITTI RODRIGUES",
qual: "49-Sócio-Administrador"
},
【问题讨论】:
-
这看起来像 json 格式。试试json_decode 和
foreach应该不错 -
你只需要计数吗
-
如果您发布完整的响应负载,我们可能会为您提供更好的帮助。如果您只需要计数,请将其分解为冒号或其他内容,然后将其包装在
sizeof()