Re: Strange explode()

From: Date: Tue, 26 Oct 2004 13:36:45 +0000
Subject: Re: Strange explode()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-200350@lists.php.net to get a copy of this message
The result is correct. You are splitting the string based on "http://". There are two instances of it, so there are 3 resulting elements. Since there is not text before the first instance, your first array element is empty. If there was text before the first instance, you would expect 3 resulting elements. Functions should always be consistent in what they return. So two instances will always give you three elements. On Oct 26, 2004, at 9:08 AM, Ryan A wrote:
Hi, Any idea why it is taking the first array as blank and giving me an array count of 3 instead of 2? <? $final="http://something.com/cgi-bin/atx/out.cgi?s=63&c=1&l=gals&u=http://bl ah.something.com/bs3/index1.htm"; $final2=explode("http://",$final); $res=count($final2); echo "<br><br><br>".$res; print_r($final2); ?> This is the output that is confusing me: Array (
    [0] =>
    [1] => something.com/cgi-bin/atx/out.cgi?s=63&c=1&l=gals&u=
    [2] => blah.something.com/bs3/index1.htm
) Thanks, Ryan --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577


« previous php.general (#200350) next »