How to remove an element from php array?

Before few days we have a requirement to remove an element from php array.

To fulfill our requirement we have used php functions.

There are three functions which can be useful to delete an element from php array.

“array_shift(array)” removes first element from an array.

“array_pop(array)” removes last element from an array.

“array_splice(array,start,length,array)” removes selected elements from an array and replaces it with new elements.

Follow the under given example to check it practically.

$array = array("first", "second", "third", "fourth", "fifth", "sixth");
array_shift($array);
array_pop($array);
array_splice($array, 0, 2);
print_r($array);

Hope this will help you.

Posted in PHP. 1 Comment »

One Response to “How to remove an element from php array?”

  1. PHP Blog Says:

    Really nice programming skills you could have there. i`m a programmer myself but I nonetheless will need to be told until I achieve your ability. great post! Check out my blog http://blog.vodoo.ro


Speak Your Mind

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: