ExcelにあってphpにはないLEFT関数とRIGHT関数がほしかったので。
my_function.php
function left($str, $num, $encoding = "UTF-8"){
return mb_substr($str, 0, $num, $encoding);
}
function right($str, $num, $encoding = "UTF-8"){
return mb_substr($str, $num * (-1), $num, $encoding);
}
echo left("あいうえお", 3); // → あいう
echo right("あいうえお", 3); // → うえお