Question: I have some data here

```
 VAN,Ford,Transit,7995
 VAN,Ford,Transit,8900
 VAN,Ford,Transit,6200

```

I have already split the data but I need to order them from cheapest van first and I have no idea where to start. Here is my code so far:

```
import java.io.BufferedReader;
import java.io.FileReader;

public class Vehicle {
    public static void main(String[]args) throws Exception
    {
        FileReader file = new FileReader("C:/Users/Aaron/Documents/java/car_file.txt");
        BufferedReader reader = new BufferedReader(file);
        String text = "";
        String line = reader.readLine();
        while (line!= null)
        {
            text += line+"\r\n";
            line = reader.readLine();
        }

        System.out.println(text);       
    }
}

```

I am guessing you make classes and sort the data some how but I don't know where to start.

Answer: 
Loop through the first array and check if the value of `$arr['id']` exists under the second array of ids. If found, add a flag as true or 1 , else false or 0.

```
foreach($arr1 as $k=>&$arr) //<--- As you can see I have  added & (Reason below)
{
   in_array($arr['id'],$arr2) ? $arr['hasID']= true : $arr['hasID']=false;
}

print_r($arr1);

```

[`Working Demo`](https://eval.in/137912)

**Reason** : To modify the array directly , you use the reference operator.

### One-liner `array_walk()`

```
array_walk($arr1,function (&$v,$k) use($arr2){ in_array($v['id'],$arr2)? $v['hasID']=true : $v['hasID']=false; });

```
```
<?php 
$arr1 = array('1'=>'shoes','2'=>'shirts','3'=>'jeans');
$arr2 = array('0'=>'1','1'=>'5','2'=>'6');

$i = 0;
foreach($arr1 as $k=>$val)
{
    if($arr2[$i] == 1)
    {
        $ARR[$k][] = $k;
        $ARR[$k][] = $val;
        $ARR[$k][] = 'true';
    }
    else
    {
        $ARR[$k][] = $k;
        $ARR[$k][] = $val;
        $ARR[$k][] = 'false';
    }
    $i++;
}
echo "<pre>";
    print_r($ARR);
echo "</pre>";
?>

```