Page 1 of 1

spltting up a string

Posted: Sun Nov 10, 2002 10:01 am
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 :)

Posted: Sun Nov 10, 2002 11:12 am
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