How To Create Dynamic Variable On The Fly Base on Array of Element and Then Truncate It
I am trying to send an array of Messages trough PHP SMS library but there are a limit of 150 character in each delivery time. so I am thinking to slice the array to several message and send them one after one.
Here is the Array which I have
- var sms = [" 1. Head west on Whiteley Ct toward Whiteley Ct (48 m)", " 2. Turn right to stay on Whiteley Ct (0.1 km)", " 3. Turn left onto 27th St (0.2 km)", " 4. Turn left onto Lynn Valley Rd (0.9 km)", " 5. Turn right onto the ramp to West Vancouver (0.3 km)", " 6. Merge onto Trans-Canada Hwy/BC-1 W (4.2 km)", " 7. Take exit 14 for Capilano Road (0.3 km)", " 8. Turn left onto Capilano Rd (0.3 km)", " 9. Turn left onto Rte 1 E (0.2 km)", " 10. Turn right onto Keith Rd (68 m)", " 11. Turn right onto Keith Rd W (0.1 km)", " 12. Turn left onto W 22 St (0.3 km)", " 13. Turn right at the 2nd cross street onto Bridgman Ave (0.1 km)", " 14. Turn left onto 21st St WDestination will be on the left (0.1 km)"];
now I need to check the length of combination of several element as long as they are less than 150 characters and truncate the variable and load the second part until finish the message? Please be inform that this is dynamic message and can contains much shorter or longer items!
Thanks