Question: i have an json and i changed to array. 

```
$asm1n = json_decode($asm_1);
print_r ($asm1n);

```

the result is 

> 
> Array ( [0] => 2 [1] => 3 )
> 
> 
> 

my problem is how to change it value based static value :
if it, 1 change to orange, 2 change apple, 3 change mango automatically

currently the value is like this in json:

```
["2","3"]

```

what i want to know how to make condition if the value like above it auto change to :

```
["apple","mango"]

```

i try use below code but i thing is wrong :

```
if ($asm1n == ["1","2","3"]){
    $asm1n = "["orange","apple","mango"]";
}

```

this all data come from database, it might have value like this ["2","3"] , ["1","2","3"], ["1","3"].

how to change the number to the value like i said before? automatically or by if condition?

Answer: 
Try this:

```
$asm1n = ["2", "3"];

$data = array();
foreach( $asm1n as $key => $value ) {
  if ( "1" === $value ) {
    $data[] = "orange";
  } elseif ( "2" === $value ) {
    $data[] = "apple";
  } elseif ( "3" === $value ) {
    $data[] = "mango";
  }
}

print_r($data);

```
You could loop through your array and change it accordingly.

```php
$fruits = [
    1 => 'orange',
    2 => 'apple',
    3 => 'mango'
];

foreach($asm1n as &$value){
    foreach($fruits as $key => $fruit){
        if($value==$key){
            $value = fruit;
        }
    }
}

```