Reputation: 462
Could somebody tell me how to remove special characters from below array in php
Array
(
[users] => Array
(
[name] => ASSOCIATION OF�CHIEFS OF USERS
)
)
Output Expected : ASSOCIATION OF CHIEFS OF USERS
Thanks
Upvotes: 0
Views: 496
Reputation: 92854
The solution using preg_replace function:
$arr = ['users' => ['name' => 'ASSOCIATION OF�CHIEFS OF USERS']];
$arr['users']['name'] = preg_replace("/[^\w [:punct:]]+/i", " ", $arr['users']['name']);
print_r($arr);
The output:
Array
(
[users] => Array
(
[name] => ASSOCIATION OF CHIEFS OF USERS
)
)
Upvotes: 1
Reputation: 42753
Just use str_replace()
echo str_replace ("�", " ", "ASSOCIATION OF�CHIEFS OF USERS");
Upvotes: 0