John Davidson

php - Check and return missing values from an array

0 comments
Message:


I am working in a laravel project. I've an array named $headings like this-


  0 => array:1 [
0 => array:5 [
0 => "name"
1 => "phone_number"
2 => "department"
3 => "division"
4 => "status"
]
]
]

And I've another sample array named $sample_data like this-


array:3 [
0 => "name"
1 => "email"
2 => "meta_data"
]

How can I get the missing values of $sample_data in $headings array & get output for this example like this-
$result=['email', 'meta_data']


Thanks in advance.



My Answer:
"Name"
1 = "Age"
2 = "Gender"
3 = "City"
4 = "Country"
5 = "Phone Number"

I want to check if any of these values are missing in the array and return the missing values. How can I do that in PHP?

Rate this post

4 of 5 based on 4739 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us