Answers for "remove specific id from array php"

PHP
1

PHP: How to remove specific element from an array?

$array = array('apple', 'orange', 'strawberry', 'blueberry', 'kiwi', 'strawberry'); //throw in another 'strawberry' to demonstrate that it removes multiple instances of the string
$array_without_strawberries = array_diff($array, array('strawberry'));
print_r($array_without_strawberries);
Posted by: Guest on May-11-2021
0

Remove a specific element from an array php

$array=array_diff($array,['strawberry']);
Posted by: Guest on June-04-2021

Code answers related to "remove specific id from array php"

Browse Popular Code Answers by Language