GremlinP1R Posted October 10, 2006 Share Posted October 10, 2006 Hai there. I'm trying to get just 2digits out a 13digit number.The number looks as follow 1234567890123 now I only whant it to show nuber 56.How can I do this? Can any one pls help me!What I tryed were$num = $row['num'];$nu = ereg_replace("[color=red]problem[/color]","",$num);Okay I'm sure there's a beter way of doing it, But thats how far my brain can think. Link to comment https://forums.phpfreaks.com/topic/23553-extracting-just-a-piece-out-of-a-13digit-number/ Share on other sites More sharing options...
trq Posted October 10, 2006 Share Posted October 10, 2006 [code=php:0]$nu = $num{5}.$num{6};[/code] Link to comment https://forums.phpfreaks.com/topic/23553-extracting-just-a-piece-out-of-a-13digit-number/#findComment-106888 Share on other sites More sharing options...
GremlinP1R Posted October 10, 2006 Author Share Posted October 10, 2006 Okay hehe my mistake!The 13digit numer always change! But just need position 5 and 6's numbers Link to comment https://forums.phpfreaks.com/topic/23553-extracting-just-a-piece-out-of-a-13digit-number/#findComment-106893 Share on other sites More sharing options...
trq Posted October 10, 2006 Share Posted October 10, 2006 My code will allways return positions 5 and 6. Link to comment https://forums.phpfreaks.com/topic/23553-extracting-just-a-piece-out-of-a-13digit-number/#findComment-106901 Share on other sites More sharing options...
GremlinP1R Posted October 10, 2006 Author Share Posted October 10, 2006 Thanx Thorpe, just had to change the 5 to 4 and 6 to 5 to get position 5 and 6.But working now. Link to comment https://forums.phpfreaks.com/topic/23553-extracting-just-a-piece-out-of-a-13digit-number/#findComment-106928 Share on other sites More sharing options...
kenrbnsn Posted October 10, 2006 Share Posted October 10, 2006 Actually your code returns position 4 & 5, since position 0 (zero) is the first position.Another way of doing it would be:[code]<?php$num = '1234567890123';$num56 = substr($num,5,2);echo $num56;?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/23553-extracting-just-a-piece-out-of-a-13digit-number/#findComment-106936 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.