How could I get only the entire first row from an array. (I use Laravel)
For example when I say:
$request-all();
I receive:
array:2 [
"email" => "[email protected]"
"password" => "adms|Wh"
]
I want to receive:
email
password
How could I get only the entire first row from an array. (I use Laravel)
For example when I say:
$request-all();
I receive:
array:2 [
"email" => "[email protected]"
"password" => "adms|Wh"
]
I want to receive:
email
password
If I understood your question correctly, you want something like this:
$keys = array_keys($array);
foreach ($keys as $key){
echo $key;
}
You can use the PHP array_keys() function to get all the keys out of an associative array.
$array = array("email"=>"[email protected]", "password"=>"adms|Wh");
Get keys from $array array
print_r(array_keys($array));
You can also use the PHP foreach loop to find or display all the keys, like this:
Loop through $array array
foreach($array as $key => $value){
echo $key . " : " . $value . "<br>";
}