Como é que eu iria agarrar os últimos 7 caracteres da corda abaixo?
Por exemplo:
$dynamicstring = "2490slkj409slk5409els";
$newstring = some_function($dynamicstring);
echo "The new string is: " . $newstring;
O que se mostraria:
The new string is: 5409els
humh... assim?
$newstring = substr($dynamicstring, -7);
Seria melhor ter um cheque antes de receber o cordel.
$newstring = substr($dynamicstring, -7);
se os caracteres forem maiores, então 7 retornam os últimos 7 caracteres retornam a string fornecida.
ou faça isso se você precisar retornar mensagem ou erro se o comprimento for inferior a 7
$newstring = (strlen($dynamicstring)>7)?substr($dynamicstring, -7):"message";