- substr: documentation ( source)
- abs: documentation ( source)
- str_repeat: documentation ( source)
- strrev: documentation ( source)
<?php
function f( $str ){
$l = strlen($str);
for( $i = -$l; $i < $l; $i++ ){
$I = abs($i);
$s = substr($str,$I,-1);
echo str_repeat(',',$I) . strrev($s) . $s . "\n";
}
}
echo "------------\n";
f(".desserts");
echo "------------\n";