ankit
Asked: In: Daily Coding Problems, Web Technology
How to delete an element from an array in PHP?
I want to delete an element from an array.
php remove value from array if exists | php remove item from array by value | array splice php | remove array from multidimensional array php | how to remove particular key from array in php | remove key from associative array php | remove object from array php | remove array inside array php | php remove key from multidimensional array | php remove array from array | remove matching element from array php | remove index from multidimensional array php
php remove value from array if exists | php remove item from array by value | array splice php | remove array from multidimensional array php | how to remove particular key from array in php | remove key from associative array php | remove object from array php | remove array inside array php | php remove key from multidimensional array | php remove array from array | remove matching element from array php | remove index from multidimensional array php
php remove value from array if exists | php remove item from array by value | array splice php | remove array from multidimensional array php | how to remove particular key from array in php | remove key from associative array php | remove object from array php | remove array inside array php | php remove key from multidimensional array | php remove array from array | remove matching element from array php | remove index from multidimensional array php
php remove value from array if exists | php remove item from array by value | array splice php | remove array from multidimensional array php | how to remove particular key from array in php | remove key from associative array php | remove object from array php | remove array inside array php | php remove key from multidimensional array | php remove array from array | remove matching element from array php | remove index from multidimensional array php
php remove value from array if exists | php remove item from array by value | array splice php | remove array from multidimensional array php | how to remove particular key from array in php | remove key from associative array php | remove object from array php | remove array inside array php | php remove key from multidimensional array | php remove array from array | remove matching element from array php | remove index from multidimensional array php
php remove value from array if exists | php remove item from array by value | array splice php | remove array from multidimensional array php | how to remove particular key from array in php | remove key from associative array php | remove object from array php | remove array inside array php | php remove key from multidimensional array | php remove array from array | remove matching element from array php | remove index from multidimensional array php php remove value from array if exists php remove item from array by value array splice php remove array from multidimensional array php how to remove particular key from array in php remove key from associative array php remove object from array php remove array inside array php php remove key from multidimensional array php remove array from array remove matching element from array php remove index from multidimensional array php
Share
<?php
// $lang is my array variable
// Delete element using unset()
$lang = array(“C”, “JAVA”, “ASP”, “C++”, “PHP”);
unset($lang[3]);
print_r ($lang);
// Delete element using array_slice()
echo “<br>”;
print_r(array_slice($lang,2));
?>
OUTPUT:
Array ( [0] => C [1] => JAVA [2] => ASP [4] => PHP )
Array ( [0] => ASP [1] => PHP )