johnmahugu

php - values to keys

Jun 14th, 2015
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.29 KB | None | 0 0
  1. /*
  2. Values2keys
  3.  
  4. Converts the values of an array to the keys of it.
  5. */
  6. function values2keys($arr, $value=1){
  7.     $new = array();
  8.     while (list($k,$v) = each($arr)){
  9.         $v = trim($v);
  10.         if ($v != ''){
  11.             $new[$v] = $value;
  12.         }
  13.     }
  14.     return $new;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment