Check if a value exits in array (Laravel or Php)

前端 未结 4 735
天涯浪人
天涯浪人 2021-02-18 17:38

I have this array:

$list_desings_ids = array(\'hc1wXBL7zCsdfMu\',\'dhdsfHddfD\',\'otheridshere\');

With a die() + var_dumo() this array return

4条回答
  •  广开言路
    2021-02-18 18:30

    You can use in_array for this.

    Try

    $design_id = 'hc1wXBL7zCsdfMu';
    $list_desings_ids = array('hc1wXBL7zCsdfMu','dhdsfHddfD','otheridshere');
    
    if(in_array($design_id, $list_desings_ids))
    {
      echo "Yes, design_id: $design_id exits in array";
    
    }
    

提交回复
热议问题