且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从数组中删除空字符串元素?

更新时间:2023-11-02 21:08:28

elt)"返回true?


谢谢, - Dave
elt)" returns true?

Thanks, - Dave


la *********** @ zipmail.com 写道:
la***********@zipmail.com wrote:

我''我使用PHP 5.我有一个字符串数组。什么是最简单的

方法来删除空元素,即表达式

" empty(
I''m using PHP 5. I have an array of strings. What is the simplest
way to remove the elements that are empty, i.e. where the expression
"empty(


elt) "返回true?
elt)" returns true?



这取决于您对简单的定义。例如,这一行

将执行:


foreach(

It depends on your definition of "simple". For example, this single line
will do:

foreach(