2016-01-07 66 views
0

這是我的輸出陣列:如何從數組中刪除空鍵值?

Array 
    ( 
    [0] =>  
    [1] =>  
    [2] =>  
    [3] =>  
    [4] =>  
    [5] =>  
    [6] =>  
    [7] => 200  
    [8] => 200 
    ) 

但我只需要: [7] => 200
[8] => 200

任何想法?

+5

'array_filter($ your_array)' – roullie

+1

'的print_r(array_filter($ your_array) );' –

+2

你可以請你的代碼有問題嗎? –

回答

1

使用array_filter()

例如,

$a= array 
( 
0 => '',  
1 => '', 
2 => '', 
3 => '', 
4 => '', 
5 => '', 
6 => '', 
7 => 200, 
8 => 200, 
); 

print_r(array_filter($a)); 
0

你可以做到這一點是:

print_r(array_filter($Array));