How to convert the key index of an array into a digital index

Source: Internet
Author: User
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        )) 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.