How to Trim Characters to 70

Hi guys, I’m trying to try trim the characters of array ( ‘title’ ) to 70 characters if they are over 70. Does anyone know how to do this please? The code I’ve got is:

$product_data[‘title’] = $product->getName();

Thankyou anyone!

$product_data[‘title’] = substr($product->getName(), 0 , 70);

Substr is used like this: substr($stringname, start-pos, length)… Hope that helps…

Sponsor our Newsletter | Privacy Policy | Terms of Service