How To Create Dynamic Variable On The Fly Base on Array of Element and Then Truncate It

215
November 26, 2016, at 7:43 PM

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

READ ALSO
jQuery: .text() is delayed

jQuery: .text() is delayed

I am learning jQuery animation functions and wirting a small game where the user has to click a moving div in a set time frameThe game is writtn so that when the time is up, the final score is displayed and a div gives the user the option to "start again"...

329
How do you intercept xhr POST parameters / POST body?

How do you intercept xhr POST parameters / POST body?

I know how to intercept AJAX calls with XMLHttpRequest

336
Wordpress flexslider with thumbnails not syncing

Wordpress flexslider with thumbnails not syncing

I am using flexslider with advanced custom fields in a wordpress site, having an issue with connecting the main slider with the thumbnailsI suspect it is the carousel at fault - the main slider animation also does not work if the carousel markup is in place

389
How to plus more 20 px to old elements using javascript?

How to plus more 20 px to old elements using javascript?

How to plus more 20 px to old elements using javascript ?

292