Hello,

I want to verify whether my $url variable has got a slash at the end of the URL string. If not, I would like to have it added.

Does it have to be done with ereg_replace? I've tried for hours and can't seem to figure it out.

Could somebody be so kind and tell me how this challenge can be tackled?

Thanks,
sama.

    Preg_replace would certainly get the job done but string functions are less greedy! Try this:

    $txt='http://mysite.com/dir/index.htm';
    $len=strlen($txt);
    if ($txt{$len-1}!='/') $txt.='/';
    echo $txt;

      thanks so much - works like a charm!

        Write a Reply...