I have an array like this:
Array
(
[0] => "<[email protected]>"
[1] => "<[email protected]>"
[2] => "<[email protected]>"
)
Now I want to remove "<" and ">" from above array so that it look like
Array
(
[0] => "[email protected]"
[1] => "[email protected]"
[2] => "[email protected]"
)
How to do this in php? Please help me out.
I'm using array_filter(); is there any easier way to do that except array_filter()?
You could take an array_walk on it:
// Removes starting and trailing < and > characters
function trim_gt_and_lt(&$value)
{
$value = trim($value, "<>");
}
array_walk($array, 'trim_gt_and_lt');
Note however that this will also remove starting > and trailing < which may not be what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With