在foreach中的多维数组 [英] Multidimensional array in foreach

查看:138
本文介绍了在foreach中的多维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想在 myformdata [languages1] [] 的内容不为空(包括零)的情况下执行foreach



我已经试过了:

$ $ $ $ $ $ $ $ $ $ $ ){



if(!empty($ form ['languages1'] [])){
foreach($ form ['languages1'] as $ val){
// do stuff
}

我不在下面的代码中,当 myformdata [languages1] [] 的输入是 0

foreach

  foreach($ form ['languages1'] as $ val){
// do stuff
}

谢谢解决方案

foreach($ form [ '语言1']为$ val)
{
//如果该值为空,则跳到下一个
if(empty($ val))
continue;

参考: http://ca.php.net/continue


i want to do the foreach only if the content of myformdata[languages1][] is not empty (include zero)

I already try:

  foreach((!empty($form['languages1']) as $val){

and

if (!empty($form['languages1'][])) {
foreach($form['languages1'] as $val){
//do stuff
}

i don't have any success. At the moment with the code below the loop is made when the input of myformdata[languages1][] is 0

foreach

foreach($form['languages1'] as $val){
//do stuff
}

thanks

解决方案

foreach ( $form['languages1'] as $val )
{
  // If the value is empty, skip to the next.
  if ( empty($val) )
    continue;
}

Reference: http://ca.php.net/continue

这篇关于在foreach中的多维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆