title: Fetch Data Array in Array From JSON and Insert Into MySQL
body: <p>I already did to fetch data in JSON and insert into MySQL. But I got a problem if the data is like array in array. I tried many methods by myself but I dont know how to do it proper for</p>
  
  <p>This is the index.php</p>
  
  <pre><code>&lt;html&gt;  
        &lt;head&gt;  
             &lt;title&gt;Media Monitoring&lt;/title&gt; 
  
       &lt;style&gt;
  
     .box
     {
      width:750px;
      padding:20px;
      background-color:#fff;
      border:1px solid #ccc;
      border-radius:5px;
      margin-top:100px;
     }
    &lt;/style&gt;
        &lt;/head&gt;  
        &lt;body&gt;  
          &lt;div class="container box"&gt;
            &lt;h3 align="center"&gt;Import JSON File Data into Mysql Database in PHP&lt;/h3&gt;&lt;br /&gt;
            &lt;?php
            $connect = mysqli_connect("localhost", "root", "", "accounts"); //Connect PHP to MySQL Database
            $query = '';
            $table_data = '';
            $filename = "json.json";
            $data = file_get_contents($filename); //Read the JSON file in PHP
            $array = json_decode($data, true); //Convert JSON String into PHP Array
            foreach($array as $row) //Extract the Array Values by using Foreach Loop
            {
             $query .= "INSERT INTO employee(name, gender, gg) VALUES ('".$row["name"]."', '".$row["gender"]."', '".$row["gg"]."'); ";  // Make Multiple Insert Query 
             $table_data .= '
              &lt;tr&gt;
         &lt;td&gt;'.$row["name"].'&lt;/td&gt;
         &lt;td&gt;'.$row["gender"].'&lt;/td&gt;
         &lt;td&gt;'.$row["gg"].'&lt;/td&gt;
        &lt;/tr&gt;
             '; //Data for display on Web page
            }
            if(mysqli_multi_query($connect, $query)) //Run Mutliple Insert Query
      {
       echo '&lt;h3&gt;Imported JSON Data&lt;/h3&gt;&lt;br /&gt;';
       echo '
        &lt;table class="table table-bordered"&gt;
          &lt;tr&gt;
           &lt;th width="45%"&gt;Name&lt;/th&gt;
           &lt;th width="10%"&gt;Gender&lt;/th&gt;
           &lt;th width="45%"&gt;Designation&lt;/th&gt;
          &lt;/tr&gt;
       ';
       echo $table_data;  
       echo '&lt;/table&gt;';
            }
  
  
  
  
            ?&gt;
       &lt;br /&gt;
           &lt;/div&gt;  
        &lt;/body&gt;  
   &lt;/html&gt; 
  </code></pre>
  
  <p>This is the editted</p>
  
  <pre><code> &lt;html&gt;  
        &lt;head&gt;  
             &lt;title&gt;Media Monitoring&lt;/title&gt; 
  
       &lt;style&gt;
  
     .box
     {
      width:750px;
      padding:20px;
      background-color:#fff;
      border:1px solid #ccc;
      border-radius:5px;
      margin-top:100px;
     }
    &lt;/style&gt;
        &lt;/head&gt;  
        &lt;body&gt;  
          &lt;div class="container box"&gt;
            &lt;h3 align="center"&gt;Import JSON File Data into Mysql Database in PHP&lt;/h3&gt;&lt;br /&gt;
            &lt;?php
            $connect = mysqli_connect("localhost", "root", "", "accounts"); //Connect PHP to MySQL Database
            $query = '';
            $table_data = '';
            $filename = "json.json";
            $data = file_get_contents($filename); //Read the JSON file in PHP
            $array = json_decode($data, true); //Convert JSON String into PHP Array
            foreach($array as $row) //Extract the Array Values by using Foreach Loop
            {
             $query .= "INSERT INTO employee(name, gender, gg) VALUES ('".$row["items""name"]."', '".$row["items"]["gender"]."', '".$row["items"].["gg"]."'); ";  // Make Multiple Insert Query 
             $table_data .= '
              &lt;tr&gt;
         &lt;td&gt;'.$row["name"].'&lt;/td&gt;
         &lt;td&gt;'.$row["gender"].'&lt;/td&gt;
         &lt;td&gt;'.$row["gg"].'&lt;/td&gt;
        &lt;/tr&gt;
             '; //Data for display on Web page
            }
            if(mysqli_multi_query($connect, $query)) //Run Mutliple Insert Query
      {
       echo '&lt;h3&gt;Imported JSON Data&lt;/h3&gt;&lt;br /&gt;';
       echo '
        &lt;table class="table table-bordered"&gt;
          &lt;tr&gt;
           &lt;th width="45%"&gt;Name&lt;/th&gt;
           &lt;th width="10%"&gt;Gender&lt;/th&gt;
           &lt;th width="45%"&gt;Designation&lt;/th&gt;
          &lt;/tr&gt;
       ';
       echo $table_data;  
       echo '&lt;/table&gt;';
            }
  
  
  
  
            ?&gt;
       &lt;br /&gt;
           &lt;/div&gt;  
        &lt;/body&gt;  
   &lt;/html&gt; 
  </code></pre>
  
  <p>JSON Data that work </p>
  
  <pre><code>[
      {  
       "name": "Rusydi",  
       "gender": "Male",  
       "gg": "System Architect"  
      },  
  
      {  
       "name": "Hakim",  
       "gender": "Male",  
       "gg": "Conservation worker"  
      }
   ]
  </code></pre>
  
  <p>JSON Data Array in Array</p>
  
  <pre><code>{  
    "items": [
      {  
       "name": "Rusydi",  
       "gender": "Male",  
       "gg": "System Architect"  
      },  
  
      {  
       "name": "Hakim",  
       "gender": "Male",  
       "gg": "Conservation worker"  
      }
   ]
   }
  </code></pre>