spltting up a string

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
zerodegreeburn
Forum Newbie
Posts: 24
Joined: Thu Jul 04, 2002 6:42 am
Contact:

spltting up a string

Post by zerodegreeburn »

i know i should use explode but i never quite got it to work right:

what im trying to do is this:

we have an ftp address

ftp://root:password@127.0.0.1:21

i want to make it so that its split up into

$user = root
$password = password
$ip = 127.0.0.1
$port = 21

ok i think i explained all , help please :)
f1nutter
Forum Contributor
Posts: 125
Joined: Wed Jun 05, 2002 12:08 pm
Location: London

Post by f1nutter »

Use parse_url.

This will create an array, with each part of the address named

Code: Select all

arrayї"host"] = 127.0.0.1
arrayї"port"] = 21
See http://www.php.net/manual/en/function.parse-url.php
Post Reply