LMSouq
php-dev Open

Get the first element of an array

HS
hsz
1 month ago
3 views
Problem Description
I have an array: `array( 4 => 'apple', 7 => 'orange', 13 => 'plum' )` I would like to get the first element of this array. Expected result: <i>string</i> `apple` One requirement: *it cannot be done with passing by reference*, so `array_shift` is not a good solution. How can I do this?

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