如何删除没有数据或为空的下一行?

I have a problem with the deleting of next line empty data using laravel. Where did I go wrong?

I tried using this code explode, str_replace and array_map but still i don't get want i want.

$string = str_replace(array("", "
"), "
", $tempData[0]);
$your_arrays = array_map("trim", explode("
", $string));

print_r ($your_arrays);

Array
(
    [0] => 
    [1] => 
    [2] => Sample Text1
    [3] => 
    [4] => Sample text 2
    [5] => Sample Text 3
    [6] => 
    [7] => 
    [8] => Sample Text 4
    [9] => Sample Text 5
    [10] => Sample Text 6
    [11] => Sample Text 7
    [12] => Sample Text 8
    [13] => 
    [14] => 
    [15] => 
)

I'm expecting the result with this

Array
(
    [1] => Sample Text1
    [2] => Sample text 2
    [3] => Sample Text 3
    [4] => Sample Text 4
    [5] => Sample Text 5
    [6] => Sample Text 6
    [7] => Sample Text 7
    [8] => Sample Text 8
)

You can use array_filter to remove all the empty entries in an array.

You can use array_filter() function.

    $var = array(
       0 => 'foo',
       1 => false,
       2 => -1,
       3 => null,
       4 => ''
   );

    print_r(array_filter($var));

You can simply use array_filter(), which conveniently handles all this for you:

print_r(array_filter($Your_Array));

use array_filter to remove all