du16178 2015-09-08 11:07
浏览 33
已采纳

每个循环都没有从数组中获取值

On using this code

echo "<pre>";
print_r($result);
echo "</pre>";

i get the following array

Array
(
    [0] => Array
        (
            [0] => S
            [1] => q
        )

    [1] => Array
        (
            [0] => C
            [1] => 
        )

    [2] => Array
        (
            [0] => G
            [1] => 3
        )

    [3] => Array
        (
            [0] => R
            [1] => 
        )

)

i wish to fetch the values and save them in database, but here i wish to save the values when both [0] and [1] has value in it. If any one of them does not hold a value then it should not be saved in database.

I tried to echo the result in [0] and [1] index place but not null value

foreach($result as $value){ 
    //echo $value['0'];    
    //echo $value['1']; 
   $result1 =  $value['0'];    
   $result2 = $value['1']; 
   if($result1!=""&&$result2!="")
     {
          //will run insert query here
     }
   }

can anyone tel how the desired result can be achieved??

  • 写回答

2条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 实值特征权重向量和特征选择,多分类
      • ¥15 INVEST年产水量模块结果出处理
      • ¥15 Neo4j 不显示关系
      • ¥15 这段代码有什么bug
      • ¥15 pip默认安装位置修改不成功
      • ¥15 C++ inline、staitc、const三合一谁能讲通透
      • ¥15 关于pyqt5中QThread的问题
      • ¥20 STM32基于HAL库使用串口发送16进制数组
      • ¥15 OpenCV报错 You can enable it via 'OPENCV_IO_ENABLE_OPENEXR'
      • ¥15 AT89C51的程序问题