How to Get First Element of Array in PHP?
How to Get First Element of Array in PHP?
I will use array_shift() and array_values() function to get first element of array using php. so, let’s see the simple full Source code of it.
index.php
<!--?php
$domain_extention = ["com", "in", "USA", "Gov"];
$firstElem = array_shift(array_values($domain_extention));
var_dump($firstElem);
?-->
Output:
string(3) "com"