Home  >  Article  >  Backend Development  >  Function application to convert variables into arrays in php

Function application to convert variables into arrays in php

WBOY
WBOYOriginal
2016-07-25 09:02:541116browse
  1. //Given variables
  2. $city = "Heze";
  3. $province = "Shandong Province";
  4. $project = "PHP Program";
  5. $location_vars = array("province" , "city");
  6. //Create an array
  7. $result = compact("project", "nothing", "location_vars");
  8. print_r($result);
  9. ?>
Copy the code

at In the above program, because there is no variable named "nothing", the output of the program is as follows: Array ( [project] => PHP Program [province] => Shandong Province [city] => Heze )



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn