@kane
The error in your code is that you are not accessing the correct array index.
Array
(
[0] => Array
(
[Product] => Resume, CV, vCard & Portfolio HTML5 Template
[Price] => 10
[Img] => http://localhost/envy-theme-new/wp-content/uploads/2019/01/cv.jpg
)
[1] => Array
(
[Product] => Runhill – Multipurpose Construction WP Theme
[Price] => 39
)
)
In your array Product index occurs after a numeric index i.e.
You can use the approach of Yasii or you can try array_map to iterate over the array of array and unset Product key.
<?php
$data=array(
array(
'Product' => 'Resume, CV, vCard & Portfolio HTML5 Template',
'Price' => 10,
'Img' => 'http://localhost/envy-theme-new/wp-content/uploads/2019/01/cv.jpg'
),
array(
'Product' => 'Runhill – Multipurpose Construction WP Theme',
'Price' => 39
)
);
$data = array_map(function($arr){
unset($arr['Product']);
return $arr;
}, $data);
echo '<pre>';
var_dump($data);
As for insert PHP array to Mysql database you need to create an insert statement from the array values and have to handle missing index values like 'Img' key value is missing your second sub-array array
Before working with arrays learn about the best way to use arrays in php here:
https://code.tutsplus.com/tutorials/working-with-php-arrays-in-the-right-way--cms-28606
Using mysql ext to insert data into the db is no longer supported in PHP7.
Please use PDO instead.
A similar query is answered here:
Insert array into MySQL database with PHP
PDO Tutorial:
https://code.tutsplus.com/tutorials/why-you-should-be-using-phps-pdo-for-database-access--net-12059