Is there a function that returns the first ## of a string, no matter how long the string is?
I tried using substr, but I will not always know the exact length of a string, its contents are coming from a database. For example:
$string1 = "Hello how are you?"
$string 2 = "Hi";
Now I only want to return the first 10 letters for each string. So for $string1 it will now be: "Hello how " and for string2, it stays exactly the same: "Hi"
I know I can use strlen to first find the length of each string, then truncate it, but now I am using 2 functions. Is there just 1 function that will allow me to do this?
Thanks