Home  >  Article  >  Backend Development  >  Convert the array into a string and restore it back to the array

Convert the array into a string and restore it back to the array

WBOY
WBOYOriginal
2016-07-25 09:02:191173browse
  1. $str = array
  2. (
  3. 'a' => 'aa',
  4. 'b' => 'bb',
  5. 'c' => array
  6. (
  7. 0 => 1,
  8. 1 => 2,
  9. 2 => 34,
  10. 3 => 4,
  11. ),
  12. );
  13. //Convert the array into a string, which can be directly stored in the database
  14. $s = var_export($str, true);
  15. //Restore back to array from string
  16. eval("$st = $s;");
  17. var_dump($st);
Copy code


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