<?php

$count = 0;
$sum = 0;
function is_prime(int $n) :bool{for($i=$n**.5|1;$i&&$n%$i--;);return!$i&&$n>1;}

for ($prime = 11; $count < 11; $prime += 2) {
    if (is_prime($prime)) {
        //echo "Testing $prime\n";
        for ($c = 1; $c < strlen($prime); $c++) {
            $left = substr($prime, -$c);
            //echo "Trimmed left $left\n";
            if (!is_prime($left)) {
                //echo "Not prime $left\n";
                continue 2;
            }
        }

        for ($c = 1; $c < strlen($prime); $c++) {
            $right = substr($prime, 0, $c);
            //echo "Trimmed right $right\n";
            if (!is_prime($right)) {
                //echo "Not prime $right\n";
                continue 2;
            }
        }
        $sum += $prime;
        $count++;
        echo "found $prime\n";
    }
}

echo "Total sum: $sum\n";
