第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

在for循環(huán)中執(zhí)行一次值

在for循環(huán)中執(zhí)行一次值

PHP
胡子哥哥 2021-05-27 23:19:33
在具有2次的數(shù)組列表[hide] => 1中,如何僅在for循環(huán)中執(zhí)行一次[hide] => 1。如何用所有先前的值檢查當(dāng)前數(shù)組并且[hide] => 1在for循環(huán)中執(zhí)行一次需要執(zhí)行[id] => 4,無(wú)需在for循環(huán)中執(zhí)行[id] => 2大批Array (     [0] => Array ( [id] => 6 [hide] => 0  )     [1] => Array ( [id] => 5  [hide] => 0 )    [2] => Array ( [id] => 4  [hide] => 1 )    [3] => Array ( [id] => 3  [hide] => 0  )    [4] => Array ( [id] => 2 [hide] => 1  ))
查看完整描述

3 回答

?
拉丁的傳說(shuō)

TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超8個(gè)贊

我想您想要ID最大的商品:


// get only the items with 'hide' = 1

$hidden = array_filter($array, function($item){return $item['hide'] == 1;});


// order the array to have the items with the greatest ID first

usort($hidden, function($a, $b){

    return $b['id'] - $a['id'] ;

});


// print the item with the max id 

print_r($hidden[0]);


查看完整回答
反對(duì) 回復(fù) 2021-05-28
?
12345678_0001

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超5個(gè)贊

嘗試這個(gè)....。您可以對(duì)關(guān)聯(lián)數(shù)組的任何深度使用此功能。


 function is_in_array($array, $key, $key_value){

    $within_array = 'no';

    foreach( $array as $k=>$v ){

      if( is_array($v) ){

          $within_array = is_in_array($v, $key, $key_value);

          if( $within_array == 'yes' ){

              break;

         }

      } else {

             if( $v == $key_value && $k == $key ){

                     $within_array = 'yes';

                     break;

             }

        }

     }

      return $within_array;

   }

   print_r(is_in_array($yourarray, 'hide', '1'));


查看完整回答
反對(duì) 回復(fù) 2021-05-28
?
慕桂英3389331

TA貢獻(xiàn)2036條經(jīng)驗(yàn) 獲得超8個(gè)贊

for($i = 0; $i<count($array); $i++){


  if($array[$i] == 4){

       print_r($array[4]);

   }

}


查看完整回答
反對(duì) 回復(fù) 2021-05-28
  • 3 回答
  • 0 關(guān)注
  • 205 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)