Question: I want to add two associative arrays to the same array key or take out only from the array the keys I need like the example below, the keys I need in the fields array `$field = [a,b];`.

Lets say I have the blow array:

```
array1 = Array
(
    [key1] => Array
        (
            [a] => a
            [b] => b
            [c] => c
        )

    [key2] => Array
        (
            [a] => a
            [b] => b
            [c] => c
        )

)

$field = [a,b];
$x = [];

foreach ($array1 as $key) {
    foreach ($fields as $field) {
        $x[$key['id']] = array($field => $key[$field]);
      }
}
print_r($x);

```

output:

```
Array
(
    [key1] => Array
        (
            [b] => b
        )

    [key2] => Array
        (
            [b] => b
        )

)

```

I need:

```
Array
(
    [key1] => Array
        (
            [a] => a
            [b] => b
        )

    [key2] => Array
        (
            [a] => a
            [b] => b
        )

)

```

Answer: 
If you want to make this common, instead of using service, you can use a `filter`

```
.filter('convertHtml',function($sce){
  return function(text){
     return $sce.trustAsHtml(text);
 }
})

<span ng-bind-html = "review.positiveText | convertHtml "> </span>

```
From the AngularJS docs: <https://docs.angularjs.org/api/ng/directive/ngBindHtml>

If you inject `ngSanitize` to the module you're using you can just use `ng-bind-html` passing a string parameter whose value is HTML.