how can i convert an index to an string ?
For example i would like to get the 'signin' index here:
array(1) {
["signin"]=>
array(2) {
["email_address"]=>
string(0) ""
["password"]=>
string(0) ""
}
}
Javi
how can i convert an index to an string ?
For example i would like to get the 'signin' index here:
array(1) {
["signin"]=>
array(2) {
["email_address"]=>
string(0) ""
["password"]=>
string(0) ""
}
}
Javi
You can use key():
reset($array); // resets the internal pointer to the first element,
// might not be necessary
$current_key = key($array);
// $current_key = 'singin';
Use array_keys() to get all keys of an array, e.g.:
$keys = array_keys('foo'=>1, 'bar'=>2);
// $keys[0] = 'foo'
// $keys[1] = 'bar'
To make sure that the key is a string you can use strval() (in case you also have numerical indecies).
......
$signin = $your_array["signin"];
To get the key, you can use the key
$key = key($your_array);
More info here: http://php.net/manual/en/function.key.php
The $signin itself is an array, you can check out:
print_r($signin);
So you can also get email address and password like this if you want:
$email = $your_array["signin"]["email_address"];
$password = $your_array["signin"]["password"];