I have a json object
'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',
),
)
I want to get the keys of the object (developer, Software Engineer, engineer, etc) and use them to search the db for matches that are in a field called Industry that is an array. I am unsure about the following.
I have searched google and stack and have not found anything helpful. Any ideas or strategies would be appreciated.
You can make that json object into a Collection :
$collection=collect(json_decode($yourObject);
And get the keys :
$keys = $collection->keys();
And you can retrieve from your data like this
$data = collect($yourData);
$results = $keys->each(function($key){
$data->only($key);
//do your logic with it
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.