Reputation: 8990
I want to grab only the first 80 characters from a string, $string
, using PHP.
Is there a function for that?
Upvotes: 0
Views: 144
Reputation: 3048
Check it out: PHP equivilent of Javascript's substring()?
The text below was written by Nick Shepherd on the topic above.
$string = 'Foo Bar!';
$from = 2;
$to = 5;
$final_string = substr($string, $from, $to - $from);
or
$string = 'Foo Bar!';
$start = 2;
$length = 5;
$final_string = substr($string, $start, $length);
Upvotes: 0