我有一个json对象
'developer' =>
array (
'count' => 1,
'docPosition' => 100,
'countCv' => 1,
'weight' => '0.077',
),
'Software Engineer' =>
array (
'count' => 4,
'docPosition' => 716,
'countCv' => 4,
'weight' => '0.308',
),
'engineer' =>
array (
'count' => 5,
'docPosition' => 725,
'countCv' => 5,
'weight' => '0.385',
),
'Software Development Engineer' =>
array (
'count' => 1,
'docPosition' => 1272,
'countCv' => 1,
'weight' => '0.077',
),
'Development Engineer' =>
array (
'count' => 1,
'docPosition' => 1281,
'countCv' => 1,
'weight' => '0.077',
),
'Contract' =>
array (
'count' => 1,
'docPosition' => 1303,
'countCv' => 1,
'weight' => '0.077',
),
)
我想获取对象的密钥(开发人员,软件工程师,工程师等),并使用它们在数据库中搜索名为Industry的数组中的匹配项。我不确定以下内容。
我搜索了谷歌和堆栈,但没有找到任何帮助。 任何想法或策略将不胜感激。
答案 0 :(得分:1)
您可以将该json对象变为Collection:
$collection=collect(json_decode($yourObject);
获得钥匙:
$keys = $collection->keys();
您可以从这样的数据中检索
$data = collect($yourData);
$results = $keys->each(function($key){
$data->only($key);
//do your logic with it
});