Results 1 to 4 of 4

Thread: Home_replace help

  1. #1
    Join Date
    Nov 2009
    Posts
    343

    Home_replace help

    Hi
    I am trying a code, but unfortunately I have no success to work it out. Following is the part of my code.
    Code:
    $link = '<a href = 'home.php' class="[home.php]">home</a>';
    From the above link in my code I want to replace my home page with my class name "active". This is what I use for it
    Code:
    home_replace('/\[*\]/', 'active', $link);
    But it seems that the code does not works at all. Any advice on this. thanks in advance.

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Home_replace help

    Hi
    In your code you have written the class name with .php extension. A class is never kept with .php.
    Code:
    $link = '<a href = 'home.php' class="[home.php]">home</a>';
    rather it should be something like this
    Code:
    $link = '<a href = 'home.php' class="[home]">home</a>';
    Please fix the problem and proceed further.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Home_replace help

    Hi
    As mentioned above you may have corrected the problem. alternatively you can also try this regular expression.
    Code:
    $patten = "/\[.*\]/";
    Can use it in your program like this
    Code:
    home_replace($patten, 'active', $link);
    Hope this will help you. Any more problem do post back.

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Home_replace help

    Hello
    Rather I would prefer not to use the "." unless necessary. I think the last solution would fail if there were two links.
    So better you this
    Code:
    $pattern = '/\[[^\]]+\]/';
    Hope this may solve your problem.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,424,809.92610 seconds with 15 queries