How to remove a specific value within an array using PHP

Written by Ian Carnaghan · 15 sec read >

If you have an array and you wish to remove the “None” values in the array you can use the method below, please replace the “None” value with the value you need to remove from the array

$array = array("Apple","Orange","None"); //The array

//Removing all None values from the array
foreach (array_keys($array, 'none') as $key) {

print_r($array); //This will output the array without the value None

Last Updated On March 22, 2018
Written by Ian Carnaghan
I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment. Profile

Leave a Reply

Notify of