|
Posted by Jeremy on 01/08/08 19:54
Michael Fesser wrote:
> .oO(bizt)
>
>> Im trying to write a regular expression in PHP to check if a submitted
>> filename has .php on the end of it. For example, filename.html woulod
>> return false whereas filename.php would return true.
>>
>> My code is:
>>
>> if (ereg ("$.php", $filename))
>> return true;
>> else
>> return false;
>>
>> Obviously my expression is wrong, could someone please tell me what Im
>> doing wrong. Thanks
>
> return pathinfo($filename, PATHINFO_EXTENSION) == 'php';
>
> Micha
Thanks for this. I had never noticed that pathinfo can return a string
rather than an array.
Jeremy
Navigation:
[Reply to this message]
|