Arrays Flashcards

1
Q

How do you map over an array?

A

array_map(‘numMultiplier’, $arr);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you get the sum of an array and how do you get the product?

A

array_sum($arr);

array_product($arr);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you filter over an array?

A

array_filter($arr, ‘bigNums’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you check whether a value is in an array?

A

in_array(2, $arr);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you see all the different values between two arrays?

A

array_diff($arr, $arr2);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you replace certain values from one array with specified values from another array?

A

array_replace($arr, array(2 => ‘Seb’));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can you remove all duplicate values from an array?

A

array_unique($arr);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How can you easily get the last item from an array?

A

end($arr);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can iterate through every item in an array?

A

foreach($arr as $name) {

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly