1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| $names = ['William', 'Peter', 'Shawn', 'John'];
$names[] = 'Micheal';
$array3 = array_merge($array1, $array2);
$names = ['William', 'Peter', 'Paul']; $people = ['John', ...$names];
$text = implode(', ', $names);
echo explode(',', $text);
echo $names[1];
unset($names[1]);
array_splice($names, 1, 1);
foreach($names as $name) { echo 'Hello ' . $name; }
echo count($names);
$person = ['age' => 45, 'genre' => 'men'];
$person['name'] = 'William';
foreach($names as $key => $value) { echo $key . ' : ' . $value; }
echo array_key_exists('age', $person);
echo array_keys($person);
echo array_values($person);
$filteredPeople = array_filter($people, function ($person) { return $person->active; });
$onlyNames = array_map(function($person) { return ['name' => $person->name]; }, $people);
$items = [ ['id' => '100', 'name' => 'product 1'], ['id' => '200', 'name' => 'product 2'], ['id' => '300', 'name' => 'product 3'], ['id' => '400', 'name' => 'product 4'], ];
$found_key = array_search('product 3', array_column($items, 'name'));
|