Page 1 of 1

Please tell me that PHP can do this?

Posted: Tue Feb 24, 2004 1:15 pm
by agency8
Check it out... I have a variable that equals "9180055512121234567" and I want to echo/print just the first 12 numbers to the web page and just drop off the last 7 numbers as these are long distance dialing codes that should not get printed.

So basically I want to format/PARSE off just the first 12 characters into a new variable.

I can do it in VB but have spent DAYS now trying to do this with PHP. IT seems sooooo esay yet I cant find PHP to just do this for me. I though it would take 5 minutes to do somthing like this as when I did it in VB but man this is becoming a joke.

Posted: Tue Feb 24, 2004 1:28 pm
by ilovetoast
Let there be code:

Code: Select all

$foo = "9180055512121234567";
$bar = substr($foo, 0, 12);

print $bar; // prints 918005551212
And it was good.

substr - Manual entry

peace

Posted: Tue Feb 24, 2004 1:28 pm
by Draco_03
Might want to take a look at that for strings functions

Posted: Tue Feb 24, 2004 1:46 pm
by agency8
dude... you guys rule. All this time I was looking at stuff like parse_str and trim and others.

Sorry for being a newbie to the PHP and thanks again. Im usre I ll be around here for a while now as all my work is being done in PHP now and not VBscript.

Thanks a million

Posted: Tue Feb 24, 2004 1:48 pm
by Draco_03
php is easy and i'm a noob too :)
no shame in it

i might be better in other field though 8)