DEV Community

Baransel
Baransel

Posted on

How to delete array in PHP

We use the unset() function, which we use to destroy variables to subtract or destroy one of the arrays you create. In fact, you can use this function to destroy all variable types.

<?php
$fruits[0] = 'Apple';
$fruits[1] = 'Pear';

// just to delete an array:
unset ($fruits[0]);
// to delete all:
unset ($fruits);
?>
Enter fullscreen mode Exit fullscreen mode

Follow my blog for more baransel.dev.

Top comments (0)