LMSouq
php-dev Open

Access first level keys with array_map() without calling `array_keys()`

JO
José Tomás Tocino
1 month ago
3 views
Problem Description
Is there a way of doing something like this: $test_array = array( "first_key" => "first_value", "second_key" => "second_value" ); var_dump( array_map( function($a, $b) { return "$a loves $b"; }, array_keys($test_array), array_values($test_array) ) ); But instead of calling `array_keys` and `array_values`, directly passing the `$test_array` variable? The desired output is: array(2) { [0]=> string(27) "first_key loves first_value" [1]=> string(29) "second_key loves second_value" }

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base