Conditions | 3 |
Paths | 3 |
Total Lines | 25 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
35 | protected function json_encode_options($options) |
||
36 | { |
||
37 | $value_arr = []; |
||
38 | $replace_keys = []; |
||
39 | |||
40 | foreach ($options as $key => &$value) { |
||
41 | // Look for values starting with 'function(' |
||
42 | if (strpos($value, 'function(') === 0) { |
||
43 | // Store function string. |
||
44 | $value_arr[] = $value; |
||
45 | // Replace function string in $foo with a 'unique' special key. |
||
46 | $value = '%'.$key.'%'; |
||
47 | // Later on, we'll look for the value, and replace it. |
||
48 | $replace_keys[] = '"'.$value.'"'; |
||
49 | } |
||
50 | } |
||
51 | |||
52 | // Now encode the array to json format |
||
53 | $json = json_encode($options); |
||
54 | |||
55 | // Replace the special keys with the original string. |
||
56 | $json = str_replace($replace_keys, $value_arr, $json); |
||
57 | |||
58 | return $json; |
||
59 | } |
||
60 | } |
||
61 |