Deprecated: Hook custom_css_loaded is deprecated since version jetpack-13.5! Use WordPress Custom CSS instead. Jetpack no longer supports Custom CSS. Read the WordPress.org documentation to learn how to apply custom styles to your site: https://wordpress.org/documentation/article/styles-overview/#applying-custom-css in /home/everyuseful/public_html/wp-includes/functions.php on line 6085
How to delete an item from an array in PHP - EveryUseful

How to delete an item from an array in PHP

To delete an item from an array in PHP you can use “unset()”

Here is an example:

$array = [1,2,3,4,5];
              
foreach( $array as $key=>$value ){
    if($value == 3){
        unset($array[$key]);
    }
}

print_r( $array);

Output:

Array
(
[0] => 1
[1] => 2
[3] => 4
[4] => 5
)

Leave a Reply

Your email address will not be published. Required fields are marked *