I have the following code, which looks perfectly fine logically, but refuses to do anything, and just gets stuck loading until it times out.
Code:
<?php
$name = "billy bobby sharkingflardo herdaderpingtonning";
while (strlen($name) > 17) {
$nameEx = explode(' ', $name);
if (strlen($nameEx[0] > 1)) {
$nameEx[0] = substr($nameEx[0], 0, -(strlen($nameEx[0]) - 1));
}
while (count($nameEx) > 2) {
unset($nameEx[1]);
}
if (strlen($nameEx[1] > 15)) {
substr($nameEx[1], 0, -1);
}
$name = implode(' ', $nameEx);
}
echo $name;
?>
I don't have much else to say, the code is needed to shorten names which are too long, it does this by reducing the first name to 1 character and removing any middle names, and if the last name alone is too long with remove a character until it is the right length.
Thanks for any help -Tom