I want to store a column of my database table in an array so I can compare it with an array I have. I am selecting only one column from the table and I am storing all the rows. I've managed to do so but in a 2d array but when comparing the 2d array to my 1d array i get an error. So please help me to convert it into a 1d array or from the begining if I can store the data in a 1d array.
$array = array();
$serviceId = "SELECT service_id FROM servicesorders WHERE order_id = '$orderId'";
$resultId = mysqli_query($connection, $serviceId) or die(mysqli_error($connection));
while ($serviceIdfinal = mysqli_fetch_assoc($resultId)) {
$array[] = $serviceIdfinal; //the array I used to store the data
}
var_dump($array);
$isCheckedstring = $_POST['show'];
$isCheckedarray = str_split($isCheckedstring, 4); // the array I want to compare the stored data with
var_dump($isCheckedarray);
the var_dump of the two arrays are as follows:
array(
[0]=> array(
["service_id"]=> "1"
)
[1]=> array(
["service_id"]=> "7"
)
[2]=> array(
["service_id"]=> "11"
)
)
And
array(
[0]=>"0011"
[1]=>"0012"
)