What is the best way to drop the first and last element in an array. For example, lets say I have the number 12345 stored as $number. How would I drop the first and last element so that it returns 234? What is the best and cleanest way to do it without too much code?
two different question s here. 12345 is not an array. do you want to strip the first and last characters of that number or do you want to know how to drop the first and last elements of an array?
My bad, I meant a scalar variable. I want to drop the first and last elements.
Something kinda like this...
<?php $number = 12345; $newnumber = substr($number, 1, (strlen($number)-2)); ?>
Good call, works like a charm. BTW, congratulations on your baby. 😃
Thanks. He's a big boy. I keep joking with my wife that he's a toddler without the motor skills. LOL
Be sure to mark the thread resolved. Have a good one.