Posted By

Biocrash on 07/13/12


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tux-world


Reindex array


 / Published in: PHP
 

  1. /**
  2.  * Ridefinisce la chiave di un array con uno degli elementi a scelta
  3.  * @param $x
  4.  * @param $key_value
  5.  * @return array
  6.  */
  7. function reindex($x, $key_value)
  8. {
  9. $ret = array();
  10. foreach($x as $_ => $v)
  11. {
  12. $ret[$v["$key_value"]] = $v;
  13. }
  14. return $ret;
  15. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Biocrash on July 13, 2012

Redefine the key of an array with one of the elements you choose.

You need to login to post a comment.