I have an array of string bits of variable length and I need to negate them.
eg.
input array("1", "00101", "101", "0000")
output array("0", "11010", "010", "1111")
Is there a simple way how to do that?
I have an array of string bits of variable length and I need to negate them.
eg.
input array("1", "00101", "101", "0000")
output array("0", "11010", "010", "1111")
Is there a simple way how to do that?
You can do this using strtr function:
$bites = array("1", "00101", "101", "0000");
$output = array_map(function($element){
return strtr($element, array('1', '0'));
}, $bites);
print_r($output);