<?php
$fruits = ['apple', 'orange', 'melon', 'banana', 'pineapple'];
echo json_encode($fruits, JSON_PRETTY_PRINT) . "\n";
foreach ($fruits as $key=>$fruit) {
if (in_array($fruit, ['apple', 'orange', 'melon', 'banana'])) {
unset($fruits[$key]);
}
}
echo json_encode($fruits, JSON_PRETTY_PRINT) . "\n";
$fruits = array_values($fruits);
echo json_encode($fruits, JSON_PRETTY_PRINT) . "\n";
preferences:
28.75 ms | 405 KiB | 5 Q