Post Details

How to Remove Specific Element by Value from Array in PHP
25 Nov

How to Remove Specific Element by Value from Array in PHP

Hi Guys,

In this tutorial, you will learn PHP to remove specific values from an array. It's a simple example of deleting specific values 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 on how to remove specific values from an array in PHP.

When I was working on my code PHP project, at that time I needed to remove specific item values from my array. I did a Google search and solved 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...

0 Comments

Leave a Comment