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. Quote Link to comment 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] Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.