Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 17th, 2012  |  syntax: None  |  size: 0.28 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. PHP: set all values in an array to something
  2. 1 = 231
  3. 2 = 432
  4. 3 = 324
  5.        
  6. $array = array(
  7.     1 => 231,
  8.     2 => 432,
  9.     3 => 324
  10. );
  11.  
  12. $array = array_flip($array);
  13.  
  14. $array = array_fill_keys(array_keys($array), 1);
  15.        
  16. $keys = array_keys($yourArray);
  17. $filled = array_fill_keys($keys, 1);