MorganFreeFarm
MorganFreeFarm

Reputation: 3733

Get first element of array as array?

From this array:

array(3) { 
    ["news_status"]=> string(1) "1" 
    ["news_input_title"]=> string(10) "test title" 
    ["news_input_description"]=> string(61) "<p>test description over 20 symbols<br></p>" 
} 

I want to get

["news_status"]=> string(1) "1" 

but to look exactly same (to be array(1)), something like this :

array(1) { 
    ["news_status"]=> string(1) "1" 
}

most functions like reset, current get only value ..

Upvotes: 0

Views: 45

Answers (1)

Richard
Richard

Reputation: 628

Try $first_element = array_slice( $myArray , 0 , 1 )

Upvotes: 2

Related Questions