如何从数组中删除空字符串元素? [英] How do I remove empty string elements from my array?
本文介绍了如何从数组中删除空字符串元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用PHP 5.我有一个字符串数组。什么是最简单的方法来删除空的元素,即表达式
" empty($ elt)"返回true?
谢谢, - Dave
Hi,
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)" returns true?
Thanks, - Dave
推荐答案
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(
这篇关于如何从数组中删除空字符串元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文