Reply to Re: Explode + url faking problem

Your name:

Reply:


Posted by Bent Stigsen on 05/29/06 14:43

frizzle wrote:
> Bent Stigsen wrote:
>> frizzle wrote:
>> [snip]
>>> $_SERVER['QUERY_STRING'] = '/artists/nirvana/mtv_unplugged'
>>> $array[0] => artists
>>> $array[1] => nirvana
>>> $array[2] => mtv_unplugged
>>> $array[3] => NULL
>> [snip]
>>
>> This one above is your real problem. You would need some mechanism to
>> determine what kind last element is, file or part of path. A lazy way
>> could be to set the criteria or just make the assumption that files
>> always has an attached extension (i.e. '.' in the name).
>>
>> For instance:
>> function DefineLoc(){
>> $loc = explode('/', trim( $_SERVER['QUERY_STRING'], '/' ) );
>> if (strrpos(end($loc), '.')===false) $loc[] = null;
>> reset($loc);
>> return $loc;
>> };
>>
>> If you have pathnames containing '.', then you would have to write
>> some code that can make the distinction.
>>
>> /Bent
>
> Actually what i have is quite similar to what you suggest. But it still
> doesn't solve my double slash problem, where the value should be NULL.

If I run this:
$url = '/artists//mtv_unplugged/';
$loc = explode('/', trim( $url, '/' ) );
if (strrpos(end($loc), '.')===false) $loc[] = null;
print_r($loc);

I get:
Array
(
[0] => artists
[1] =>
[2] => mtv_unplugged
[3] =>
)

Isn't that what you want?


/Bent

[snip]

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация