How to Remove Specific Element by Value from Array in PHP?

By Hardik Savani May 14, 2024 Category : PHP

Hello Folks,

In this tutorial, you will learn php remove specific value from array. It's a simple example of delete specific value from array php. step by step explain remove value from array php. let’s discuss about array_diff example php. Follow the below tutorial step of how to remove specific value from array in php.

When I was working on my code PHP project, at that time I need to remove specific items value from my array. I did a google search and solve that but I would like to share on my site how to remove value from the array. so, let's see how to use:

Example:

index.php

<?php

$myArray = ['php', 'laravel', '.net', 'java', 'c#', 'javascript'];

$myArray = array_diff($myArray, ['laravel']);

print_r($myArray);

?>

Output:

Array

(

[0] => php

[2] => .net

[3] => java

[4] => c#

[5] => javascript

)

I hope it can help you...

Tags :
Shares