Re: Split problems...

From: Date: Thu, 27 Jul 2000 11:43:44 +0000
Subject: Re: Split problems...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-8531@lists.php.net to get a copy of this message
split() takes a regex - so you'd need to escape the period like this \. but you don't need regex, you can just use explode() which takes a string $data = explode(".", "127.0.0.1"); for($i=0;$i<count($data);$i++) echo $data[$i]."\n"; jason > Split problems... > > I want tp split an Ip-Adresse (like 127.0.0.1) into pieces (127, 0, 0, > 1) > > I tried: > > $ip_list = split(".", "127.0.0.1"); > print "Items:".count($ip_list)."<BR>"; > > # First problem: Delivers Items: 10 (should be 4) > > for($i=0; $i<4; $i++) > { $a = $ip_list[$i]; > echo "$i: $a<BR>"; > > # Second Problem: $a is always mpty > } > > Any ideas ? > > Regards > > Martin > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#8531) next »