daily pastebin goal
88%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. categories['t-shirts'] = 10
  2. categories['shorts'] = 11
  3. ...
  4.  
  5. clothing[0] = 't-shirts'
  6. clothing[1] = 'shorts'
  7. ...
  8.    
  9. foreach($clothing as $key => $val){
  10.     if(isset($categories[$val])){
  11.          $clothing[$key] = $categories[$val];
  12.     }
  13. }
  14.    
  15. categories[clothing[0]] = "some value"
  16.    
  17. $newArray=array_keys($originalArray);
  18.    
  19. $count = count($clothing);
  20. for($i=0; $i<$count; $i++)
  21.     $clothing[$i] = (array_key_exists($clothing[$i], $categories))
  22.         ? $categories[$clothing[$i]] : 0;
  23.    
  24. $categories = array();
  25. $categories['t-shirts'] = 10;
  26. $categories['shorts'] = 11;
  27.  
  28. $clothing = array();
  29. $clothing[0] = 't-shirts';
  30. $clothing[1] = 'shorts';
  31.  
  32. array_walk($clothing,
  33.            function(&$value) use($categories) {
  34.                if (isset($categories[$value]))
  35.                    $value = $categories[$value];
  36.            }
  37. );
  38. var_dump($clothing);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top