How to convert the key index of an array into a digital index? For example, the information I read from the INI file is a one-dimensional array: this is my INI file [web] hostlocalhostconnuserrootconnpwdrootconndbmyofficePHPcode read file functionReadConfig ($ filename) {how to convert the array key index into digital?
For example, the information I read from the INI file is a one-dimensional array:
This is my INI file
[Web]
Host = localhost
Connuser = root
Connpwd = root
Conndb = myoffice
PHP code
// Read the file function ReadConfig ($ filename) {if (file_exists ($ filename) = false) {// echo"
The file ". $ filename." does not exist!
"; Return NULL;} return parse_ini_file ($ filename, true);} // test $ Setting = array (); $ res = array (); $ Setting = ReadConfig ("webconfig. ini "); print_r ($ Setting );
I don't want this array with keys, because I'm not used to it, so I want to convert it into this -- use the array number subscript index numbers 0, 1, 2, 3 ,...
$ Res [0] = localhost;
$ Res [1] = root;
...
Instead of $ Setting ["host"] = localhost?
------ Solution --------------------
Array_values ();
------ Solution --------------------
You have
Return parse_ini_file ($ filename, true );
Therefore, the returned array is a two-dimensional array.
PHP code
Array( [web] => Array ( [host] => localhost [connuser] => root [connpwd] => root [conndb] => myoffice ))