I am trying to convert the special chars in my array to html entity codes:
this is my helper array:
'specialChars' => [
'!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+',
',', '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\',
']', '^', '_', '`', '{', '|', '}', '§', '©', '¶'
]
And this is the function:
public static function convert($specialChars = [])
{
$htmlEntityArray = [];
if(count($specialChars) == 0)
{
$specialChars = Config::get('constants.specialChars'); // gets the special char from the helper array
}
foreach ($specialChars as $key => $value)
{
$htmlEntityArray = array_map("htmlentities", $specialChars);
}
return $htmlEntityArray;
}
But that only returns me this array, it convert some successfully and some not:
array:32 [▼
0 => "!"
1 => """
2 => "#"
3 => "$"
4 => "%"
5 => "&"
6 => "'"
7 => "("
8 => ")"
9 => "*"
10 => "+"
11 => ","
12 => "/"
13 => ":"
14 => ";"
15 => "<"
16 => "="
17 => ">"
18 => "?"
19 => "@"
20 => "["
21 => "\"
22 => "]"
23 => "^"
24 => "_"
25 => "`"
26 => "{"
27 => "|"
28 => "}"
29 => "§"
30 => "©"
31 => "¶"
]
htmlentitiesorhtmlspecialcharsfunctions, which are made to do this