Jump to content

Archived

This topic is now archived and is closed to further replies.

GremlinP1R

extracting just a piece out of a 13digit number

Recommended Posts

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.

Share this post


Link to post
Share on other sites
[code=php:0]
$nu = $num{5}.$num{6};
[/code]

Share this post


Link to post
Share on other sites
Okay hehe my mistake!

The 13digit numer always change! But just need position 5 and 6's numbers

Share this post


Link to post
Share on other sites
My code will allways return positions 5 and 6.

Share this post


Link to post
Share on other sites
Thanx Thorpe, just had to change the 5 to 4 and 6 to 5 to get position 5 and 6.
But working now.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.