How to choose from an array(of array(of array)) separate data and write into mysql?

The crux of the matter:
The data is processed by json_decode() just a question: is a string or objects?:
Data

stdClass Object ( [data] => Array ( [0] => stdClass Object ( [id] => 216710 [name] => Office [parent_id] => 0 [depth_level] => 1 ) [1] => stdClass Object ( [id] => 216878 [name] => dental equipment [parent_id] => 216710 [depth_level] => 2 ) [2] => stdClass Object ( [id] => 216879 [name] => Paper white classes A, b, C [parent_id] => 216878 [depth_level] => 3 ) [3] => stdClass Object ( [id] => 216887 [name] => white Paper premium [parent_id] => 216878 [depth_level] => 3 ) [4] => stdClass Object ( [id] => 216888 [name] => Paper with a magnetic layer [parent_id] => 216878 [depth_level] => 3 ) [5] => stdClass Object ( [id] => 216889 [name] => Paper for transfer image on fabric [parent_id] => 216878 [depth_level] => 3 ) [6] => stdClass Object ( [id] => 216882 [name] => Paper colored office [parent_id] => 216878 [depth_level] => 3 ) [7] => stdClass Object ( [id] => 216880 [name] => Paper writing [parent_id] => 216878 [depth_level] => 3 ) [8] => stdClass Object ( [id] => 216881 [name] => perforated Paper [parent_id] => 216878 [depth_level] => 3 ) [9] => stdClass Object ( [id] => 216890 [name] => Paper for drawing and copying of works [parent_id] => 216878 [depth_level] => 3 ) [10] => stdClass Object ( [id] => 216891 [name] => Paper (carbon paper) [parent_id] => 216890 [depth_level] => 4 ) [11] => stdClass Object ( [id] => 216894 [name] => Paper scale-coordinate [parent_id] => 216890 [depth_level] => 4 ) [12] => stdClass Object ( [id] => 216892 [name] => Paper [parent_id] => 216890 [depth_level] => 4 ) [13] => stdClass Object ( [id] => 216893 [name] => Blueprint [parent_id] => 216890 [depth_level] => 4 ) [14] => stdClass Object ( [id] => 216884 [name] => Paper for large format printing [parent_id] => 216878 [depth_level] => 3 ) [15] => stdClass Object ( [id] => 216885 [name] => Rolls for printer [parent_id] => 216878 [depth_level] => 3 ) [16] => stdClass Object ( [id] => 216886 [name] => Rolls for Fax [parent_id] => 216878 [depth_level] => 3 ) [17] => stdClass Object ( [id] => 216895 [name] => Rolls for cash registers, ATMs and terminals [parent_id] => 216878 [depth_level] => 3 ) [18] => stdClass Object ( [id] => 216898 [name] => Rolls for cash registers thermal paper from [parent_id] => 216895 [depth_level] => 4 ) [19] => stdClass Object ( [id] => 216897 [name] => Rolls for cash registers offset [parent_id] => 216895 [depth_level] => 4 ) [20] => stdClass Object ( [id] => 216899 [name] => Rolls for terminals and ATMs from thermal paper [parent_id] => 216895 [depth_level] => 4 ) [21] => stdClass Object ( [id] => 216900 [name] => Design and certificate paper [parent_id] => 216878 [depth_level] => 3 )))


These data need only id and parent_level.
write to the database:
5e295d75d6e19744898274.jpeg

Accordingly, in the category_id and parent_id.
Please help me to compile php

I also then have to do for items, so if you don't mind, comment your code.
April 4th 20 at 13:27
2 answers
April 4th 20 at 13:29
Solution
Here's how to get to all the category_id and parent_id
foreach ($data as $k){
 foreach ($k as $find => $v){
 if(($v["id"]) !== NULL || ($v["parent_id"]) !== NULL){

 $category_id = ($v["id"]);
 $parent_id = ($v["parent_id"]);
}
}
April 4th 20 at 13:31
php.net/json_decode pay attention to the second parameter
php.net/foreach discover the cycles. hint: inside the cycle can be placed one cycle.
Code

<?PHP
 require 'config/cat.php';
 if($data = json_decod($result)){
 foreach($data as $k=>$v){
 foreach($v as $k1=>$v1){

 foreach($v1 as $k2=>$v2){

}
}
}

?>


Got to the array data( using foreach), what to do next? - dillon commented on April 4th 20 at 13:34
Write to database - Quinten.Rob commented on April 4th 20 at 13:37
@Quinten.Rob, the code show on the basis of data - dillon commented on April 4th 20 at 13:40
code show

You're not a policeman work? - Quinten.Rob commented on April 4th 20 at 13:43
@Quinten.Rob, https://мвд.рф/opendata - discover new horizons of opendata - dillon commented on April 4th 20 at 13:46
I see you're a demanding man.
You only have not forgotten the case that came here hat in hand begging to ask? - Quinten.Rob commented on April 4th 20 at 13:49
@Quinten.Rob, this is how you introduce yourself here is. well help you have to ask yourself is not respected. - dillon commented on April 4th 20 at 13:52
You pozitsioniruesh. And you don't ask for help, and stupid to do everything for you. Are two different things. - Quinten.Rob commented on April 4th 20 at 13:55
Hands outstretched, begging, where are you getting this, then who do you think you are? stupid for me to do is not stupid for me, if you say and advise anything sensible did not intend, and it would not start.
YOU'RE JUST NASTY, IF NOT NOTICED. - dillon commented on April 4th 20 at 13:58
What are you? - Quinten.Rob commented on April 4th 20 at 14:01

Find more questions by tags PHPMySQL