{"id":5419,"date":"2018-03-22T16:37:01","date_gmt":"2018-03-22T21:37:01","guid":{"rendered":"http:\/\/www.carnaghan.com\/?post_type=epkb_post_type_1&p=5419"},"modified":"2018-03-22T16:37:01","modified_gmt":"2018-03-22T21:37:01","slug":"how-to-remove-all-0s-zeros-from-an-php-array","status":"publish","type":"epkb_post_type_1","link":"https:\/\/www.carnaghan.com\/knowledge-base\/how-to-remove-all-0s-zeros-from-an-php-array\/","title":{"rendered":"How to remove all 0’s (zeros) from an PHP array"},"content":{"rendered":"
If I have the following PHP array<\/p>\n
$array = array(9,0,6,4,5,0,9,0,0,0);<\/pre>\n<\/div>\n<\/div>\nand I need to have all 0’s removed from it.<\/p>\n
Use the PHP\u00a0array_filter<\/strong>\u00a0function. If you don’t supply a callback function it will filter out all values that are equal to false<\/p>\n\n\n$new_array = array_filter($array);<\/pre>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"If I have the following PHP array $array = array(9,0,6,4,5,0,9,0,0,0); and I need to have all 0’s removed from it. Use the PHP\u00a0array_filter\u00a0function. If you don’t supply a callback function it will filter out all values that are equal to false $new_array = array_filter($array);<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"epkb_post_type_1_category":[4437],"epkb_post_type_1_tag":[],"yoast_head":"\n
How to remove all 0's (zeros) from an PHP array - Ian Carnaghan<\/title>\n\n\n\n\n\n\n\n\n\n\n