🚗🏍️ Welcome to Motoshare!

Turning Idle Vehicles into Shared Rides & New Earnings.
Why let your bike or car sit idle when it can earn for you and move someone else forward?

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Partners earn. Renters ride. Everyone wins.

Start Your Journey with Motoshare

Get First Element of Array

php

This example will teach you how to retrieve the first element of an array in PHP. I simply walked you through the process of getting the first element of an array in PHP. I simply provided an example of how to use php to fetch the first key of an array. I would like to demonstrate how to retrieve the first key value from an array in PHP.

To retrieve the first element of an array in PHP, we will utilize the array_shift() and array_values() functions. So let us look at the short code for it.

Eaxmple

<?php
  
   $myArray = ["One", "Two", "Three", "Four"];
      
   $firstElem = array_shift(array_values($myArray));   
     
   var_dump($firstElem);
     
?>

OutPut:

string(3) "One"
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x