Jump to content

Archived

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

wiegs

need a little help here!!!

Recommended Posts

I need to figure out a way to extract only numberic data from one field into another.

original data:
test2345.gif


results I would like:
2345

please help! I have spent way to much time trying to figure this out.

Share this post


Link to post
Share on other sites
Something like this should work:

[code]$s = "test2345.gif";

function getnumbers($str) {
    $ret = "";
    for ($i = 0; $i <= strlen($str); $i++) {
        if (is_numeric($str{$i})) {
            $ret .= $str{$i};
        }
    }
    return $ret;
}

echo getnumbers($s);[/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=355806:date=Mar 16 2006, 09:50 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Mar 16 2006, 09:50 PM) [snapback]355806[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Something like this should work:

[code]$s = "test2345.gif";

function getnumbers($str) {
    $ret = "";
    for ($i = 0; $i <= strlen($str); $i++) {
        if (is_numeric($str{$i})) {
            $ret .= $str{$i};
        }
    }
    return $ret;
}

echo getnumbers($s);[/code]
[/quote]


this worked great. thanks!

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.