Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize emptying and not zeroing in php array

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to empty and not zero the php array". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "php array how to achieve empty do not go zero" it!

The way to get rid of emptiness and no zeros in the php array is to use strlen as the callback function, which implements code statements such as "array_filter ($array, 'strlen');".

Operating environment of this article: Windows7 system, PHP7.1 version, Dell G3 computer

How can php array be empty or not zero?

Specific problem description:

I want to delete the NULL,FALSE and''values. I used array_filter, but I also deleted 0.

Is there any way?

Array (NULL,FALSE,'',0,1)-> array (0quotient 1)

Solution:

From http://php.net/manual/en/function.array-filter.php#111091:

If you want to delete NULL,FALSE and empty strings, but leave the value 0, you can use strlen as the callback function:

Array_filter ($array, 'strlen')

At this point, I believe you have a deeper understanding of "how to empty and not zero the php array". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report