-6

I have an array [0,1,2,3,4] if i got ApplicationStatus = 868 at first then it return only that value other are remove from array. My actual array and i want expected array as below. Actual Array -

Array
(
    [0] => Array
        (
            [Name] => DENNIS VICENCIO BLANCO
            [ApplicationStatus] => 826
        )

    [1] => Array
        (
            [Name] => ARPITA RANJAN DUTTA
            [ApplicationStatus] => 826
        )

    [2] => Array
        (
            [Name] => MARLUNA LIM URUBIO
            [ApplicationStatus] => 868
        )

    [3] => Array
        (
            [Name] => BREDJET - ALEXANDER
            [ApplicationStatus] => 868
        )

    [4] => Array
        (
            [Name] => DENNIS VICENCIO BLANCO
            [ApplicationStatus] => 826
        )

)

Expected Array -
Array
(
    [0] => Array
        (
            [Name] => DENNIS VICENCIO BLANCO
            [ApplicationStatus] => 826
        )

    [1] => Array
        (
            [Name] => ARPITA RANJAN DUTTA
            [ApplicationStatus] => 826
        )

    [2] => Array
        (
            [Name] => MARLUNA LIM URUBIO
            [ApplicationStatus] => 868
        )    
)

So,how to remove remaining key from array.please suggest mi appropriate solution for this.

Amit BBV
  • 11
  • 1
  • Possible duplicate of http://stackoverflow.com/questions/369602/delete-an-element-from-an-array - not voting to as this would golden-hammer the question. – Fluffeh Dec 19 '14 at 10:20
  • No i want to travers upto that ApplicationStatus =868,after that unset all. – Amit BBV Dec 19 '14 at 10:24

2 Answers2

0

Not very clear, but you can delete a value from an array with unset() function. For example:

unset($arr[3]); // removes array with key = 3

...but I would use the array_filter() and would create a function to select the right elements what I need.

Seer
  • 739
  • 4
  • 22
0

You can use array slice function:

$desired_array = array();
for($i = 0; $i < count($my_array); $i++)
{
    if($my_array[$i]["ApplicationStatus"] == 868)
    {
        $desired_array = array_slice($my_array, 0, $i);
    }
}
isa
  • 462
  • 2
  • 7
  • 17