$array = array('name' => 'John', 'age' => 25); $assoc = Arr::is_assoc($array); if ($assoc) { echo "The array is associative."; } else { echo "The array is not associative."; }
The array is associative.In this example, we have declared an array with string keys and then used the Arr::is_assoc() function to check whether it is an associative array or not. Since the array has string keys, the function returns true and outputs the message "The array is associative." This function is a part of Laravel's Illuminate\Support\Arr package library.