Remove empty array elements

前端 未结 27 3491
半阙折子戏
半阙折子戏 2020-11-21 23:17

Some elements in my array are empty strings based on what the user has submitted. I need to remove those elements. I have this:

foreach($linksArray as $link)         


        
27条回答
  •  别跟我提以往
    2020-11-21 23:44

    As per your method, you can just catch those elements in an another array and use that one like follows,

    foreach($linksArray as $link){
       if(!empty($link)){
          $new_arr[] = $link
       }
    }
    
    print_r($new_arr);
    

提交回复
热议问题