Home / Tips / Programming languages / Scripting languages / PHP / How to remove an element from an array in PHP

How to remove an element from an array in PHP

PHP
 
PHP
  • Currently 0 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 0/5 (0 votes cast)

Thank you for rating!

You have already rated this page, you can only rate it once!

Your rating has been changed, thanks for rating!

Log in or create a user account to rate this page.


An element can be removed from an array by using PHP function unset.

To delete a specific element from an array, use index of the element:

$figures = array( 1, 2, 3, 4 );
unset( $figures[ 2 ] );

The element with the value 3 will be removed from the array.


 

Read also

Classes and objects in PHP: destructors

Classes and objects in PHP: destructors

What is PHP?

What is PHP?

Classes and objects in PHP

Classes and objects in PHP

Post comment

basicuse.net
html5_css
106160485398655174790

Quick navigation

General navigation