Voting

: min(three, eight)?
(Example: nine)

The Note You're Voting On

post [at] jannik - zappe [dot] de
16 years ago
Just a little function to cut a string by the wanted amount. Works in both directions.

<?php
function cutString($str, $amount = 1, $dir = "right")
{
if((
$n = strlen($str)) > 0)
{
if(
$dir == "right")
{
$start = 0;
$end = $n-$amount;
} elseif(
$dir == "left") {
$start = $amount;
$end = $n;
}

return
substr($str, $start, $end);
} else return
false;
}
?>

Enjoy ;)

<< Back to user notes page

To Top