Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- categories['t-shirts'] = 10
- categories['shorts'] = 11
- ...
- clothing[0] = 't-shirts'
- clothing[1] = 'shorts'
- ...
- foreach($clothing as $key => $val){
- if(isset($categories[$val])){
- $clothing[$key] = $categories[$val];
- }
- }
- categories[clothing[0]] = "some value"
- $newArray=array_keys($originalArray);
- $count = count($clothing);
- for($i=0; $i<$count; $i++)
- $clothing[$i] = (array_key_exists($clothing[$i], $categories))
- ? $categories[$clothing[$i]] : 0;
- $categories = array();
- $categories['t-shirts'] = 10;
- $categories['shorts'] = 11;
- $clothing = array();
- $clothing[0] = 't-shirts';
- $clothing[1] = 'shorts';
- array_walk($clothing,
- function(&$value) use($categories) {
- if (isset($categories[$value]))
- $value = $categories[$value];
- }
- );
- var_dump($clothing);
Add Comment
Please, Sign In to add comment