Get the App
SLTechnology News&Howtos  ›  Development  › 

How to remove duplicates of one-dimensional array, delete zero zero null and reset index by php

Shulou Source: shulou.com Published: 2022-06-01 04:49:49 09月29日 Update

Xiaobian to share with you how php to achieve a one-dimensional array to weight, delete 0,null, index reset, I hope you have something to gain after reading this article, let's discuss it together!

One-dimensional array de-duplication, delete 0,null, index reset

$array = array (0,1,0,2,null,1,3,4,null,0);$array = array_values (array_unique(array_diff($array, [0, null]))); //remove 0,null; remove var_export($array); /* output: array ( 0 => 1, 1 => 2, 2 => 3, 3 => 4,)*/After reading this article, I believe you have a certain understanding of "how to achieve one-dimensional array de-duplication, delete 0,null, index reset". If you want to know more about it, welcome to pay attention to the industry information channel. Thank you for reading!

Tags: Array index one-dimensional article done more knowledge industry information information channel channel output Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Xiaomi Microsoft vpn Shulou Information