Posted By

anagaiyahoocom on 06/11/11


Tagged

php


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tux-world


Convert key/value string into associated array


 / Published in: PHP
 

  1. /**
  2. * Will turn key=value string into associated array
  3. *
  4. * @param string $str key/value string to convert to array
  5.   * @param string $delim
  6. * @return array
  7. */
  8.  
  9. function explode_to_assoc_array($str,$delim)
  10. {
  11. $result = array();
  12.  
  13. foreach (explode('&', $str) as $couple) {
  14. list ($key, $val) = explode('=', $couple);
  15. $result[$key] = $val;
  16. }
  17.  
  18. return $result;
  19. }

Report this snippet  

You need to login to post a comment.