|
Posted by ColdShine on 03/18/06 03:19
frizzle in news:1142640199.152903.92170@p10g2000cwp.googlegroups.com wrote:
> $_GET['artile'] looks like this: /2006/03/lorem_ipsum
>
> $locationinfo = explode('/', trim( $_GET['article'] , '/') );
>
> list( $article_year, $article_month, $article_url ) = $locationinfo;
>
> echo '<br>year: '.(($article_year === NULL)? 'null': $article_year);
> echo '<br>month: '.(($article_month === NULL)? 'null': $article_month);
> echo '<br>article: '.(($article_url === NULL)? 'null': $article_url);
>
> The weird thing is, if $_GET['article'] is empty, $article_year isn't
> NULL, but the rest is. This doesn't make any sense to me ...
When there's no match for the specified delimiter, explode() returns an
array with 1 item (the entire source string). So, assigning this to
list(...) results in the first list() argument being assigned the value of
the 1st (and only) item in the array, and the remaining list() arguments are
set to null (or simply still unset? I don't know).
So, as in your case, you get trim($_GET['article'], '/') == ''; explode('/',
'') returns array(''), and list($a_y, $a_m, $a_u) translates into $a_y = '';
$a_m = null, $a_u = null.
--
ColdShine
"Experience is a hard teacher: she gives the test first, the lesson
afterwards." - Vernon Sanders law
Navigation:
[Reply to this message]
|