I have an array with multiple strings, like this:
$str[0] = "kasdnkjsandjabsdkjsbad";
$str[1] = "kasdnkjsandjasdjksabdjkasbkjdsak";
$str[2] = "kasdnkjsandsadbaskjdbsakjdbasdsadjsadjksabdk";
$str[3] = "kasdnkjsandasdjbaskdbjsakbdkjsabdjksabdkjsabdjkasbdjksa";
$str[4] = "kasdnkjsandsajdbaskjdbjksabdjkbasjkdbjksadbjksadbjksadbjksadbkjsa";
$str[5] = "kasdnkjsandasdjbsakdjbsakjdbsakjdsakjdbjksabdjksabdkjasbkjdasbkjdbsakjdsabjk";
Is there any way i can limit the string length of all arrays, assuming i don’t know how many strings there will be in a certain array.
Thanks,
Well, theoretically, this is pretty simple: just create a function that will “limit” the length of the string, and if it’s too long, strip it off:
EDIT: if you want to “limit” the number of characters while adding them to the array, you can simply create a check in a function: