Please tell me that PHP can do this?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
agency8
Forum Newbie
Posts: 3
Joined: Tue Feb 24, 2004 1:15 pm

Please tell me that PHP can do this?

Post 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.
ilovetoast
Forum Contributor
Posts: 142
Joined: Thu Jan 15, 2004 7:34 pm

Post 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
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

Might want to take a look at that for strings functions
agency8
Forum Newbie
Posts: 3
Joined: Tue Feb 24, 2004 1:15 pm

Post 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
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post 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)
Post Reply