xeidor Posted March 8, 2007 Share Posted March 8, 2007 I have a number such as 1234 in a database, what I would like to do is just select the first two digits of the number and ignore the last two. I need just the first two numbers to do a calculation with. Does anyone know of a way to do this in php? Thanks for any help Link to comment https://forums.phpfreaks.com/topic/41720-solved-selecting-digits-out-of-a-number/ Share on other sites More sharing options...
skali Posted March 8, 2007 Share Posted March 8, 2007 <?php $num = 12345; $num = strval($num); $num = substr($num,0,2); $num = intval($num); ?> Link to comment https://forums.phpfreaks.com/topic/41720-solved-selecting-digits-out-of-a-number/#findComment-202264 Share on other sites More sharing options...
xeidor Posted March 8, 2007 Author Share Posted March 8, 2007 Works great, thanks for your time. Link to comment https://forums.phpfreaks.com/topic/41720-solved-selecting-digits-out-of-a-number/#findComment-202284 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.