Home > Backend Development > PHP Tutorial > 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
Release: 2016-07-25 09:02:19
Original
1240 people have browsed it
  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


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template