Flipping bits function written in PHP

In this post, I will show three solutions with benchmark test of flipping 32 bits unsigned integer's bits.
Three implementations can be seen below, they are named flippingBits1, flippingBits2 and flippingBits3.
The tests were executed 1000000 times flippingBits with follow inputs: 1, 23423, 234112321321313.

I executed on brand new machine several times and I find out average result, which is:
flippingBits1 - executed for 1.122 seconds.
flippingBits2 - executed for 27.193 seconds.
flippingBits3 - executed for 15.628 seconds.

There is a huge difference which can be seen easily, flippingBits1 was executed for 26.071 sceonds faster from flippingBits2, which make it ~2423.62%.
function flippingBits1($intInput)
{
    // collect least significan bit before shift
    $leastSignificantBit = ($intInput & 1);

    $intInput = ($intInput >> 1 | 0x80000000);
    $intInput = (~$intInput & 0xFFFFFFFF); // cast to 32 bit 

    // put back least significan bit 
    $intInput = $intInput << 1;
    
    // if necessecy change it
    if ($leastSignificantBit == 0) {
        $intInput = ($intInput | 1);
    }

    return $intInput;
}

function flippingBits2($intInput)
{
    $intInput = sprintf('%032b', $intInput);
    $len = mb_strlen($intInput);

    for ($i = 0; $i < $len; $i++) {
        $val = $intInput[$i];

        if ($val == "1") {
            $intInput[$i] = "0";
        } else {
            $intInput[$i] = "1";
        }
    }

    return bindec($intInput);
}

function flippingBits3($intInput)
{
    $intInput = sprintf('%032b', $intInput);
    
    $swapFrom = [0,1];
    $intInput = str_replace($swapFrom, [2,3], $intInput);
    $intInput = str_replace([3,2], $swapFrom, $intInput);

    return bindec($intInput);
}

The flippingBits1 was test with.
$before = microtime(true);
for ($i = 0; $i < 1000000; $i++) {
    flippingBits1(1);
    flippingBits1(23423);
    flippingBits1(234112321321313);
}
$after = microtime(true);
echo ($after-$before);

The flippingBits2 was test with.
$before = microtime(true);
for ($i = 0; $i < 1000000; $i++) {
    flippingBits2(1);
    flippingBits2(23423);
    flippingBits2(234112321321313);
}
$after = microtime(true);
echo ($after-$before);

The flippingBits3 was test with.
$before = microtime(true);
for ($i = 0; $i < 1000000; $i++) {
    flippingBits3(1);
    flippingBits3(23423);
    flippingBits3(234112321321313);
}
$after = microtime(true);
echo ($after-$before);