| Viewed 14 times

How to checks whether the given array is an associative array in laravel


How to checks whether the given array is an associative array in laravel

1 Answer
Mohammad Qandeel
Answered
0

You can use the isAssoc() helper function to checks whether the given array is an associative array in laravel

For Laravel developers when you get an array and you don't know the type of array.

If you want to check whether the given array is an associative array in laravel you can use the isAssoc() helper function which will return true if the given array is an associative array and  returns false if the given array is not an associative array

Example of how to use isAssoc() helper function

 

$isAssoc = Arr::isAssoc(['product' => ['name' => 'Desk', 'price' => 100]]);

Output

true



Related FAQ