For such a trivial thing you could just use [man]basename[/man]

    Alright that worked hwoever I got another question....

    How would I do preg_replace for the following value "The Site Title - Page Category"

    All I want from that is "Page"

    I know how to remove the string behind it just not after it, it keeps displaying Page Category to me

    	$strtitle = preg_replace ("/The Site Title  - /i",'',$newtitle);

      Untested:

      $strtitle = preg_replace('/.*\s+-\s+(\S*).*/', '\\1', $newtitle);
      

        Try something like this

         $strtitle = preg_replace('/.*- (\w+).*/', '\\1', $newtitle);
          5 years later

          Hi there, this is my URL:
          http://www.tweewielersite.nl/tweewielersite/sendtoafriend-form.php?id_product=http://www.tweewielersite.nl/tweewielersite/102-sparta-e-motion-damesfiets.html

          	function hookExtraLeft($params)    
          {
          global $cookie, $link, $smarty; /* Product informations */ $product = new Product(intval(Tools::getValue('id_product')), false, intval($cookie->id_lang)); $productLink = $link->getProductLink($product->id, $product->link_rewrite); $smarty->assign('productLink', parse_url($productLink,PHP_URL_QUERY)); // $productLink = preg_replace("/[^\/]*$/","",$productLink);
          $productLink = preg_replace("/http://www.tweewielersite.nl/tweewielersite/$","",$productLink);
          print_r($productLink); $smarty->assign(array( 'this_path' => $this_path, 'product' => $product, 'productLink' => $productLink ));
          <li><a href="{$this_path}sendtoafriend-form.php?id_product={$productLink}"><IMG SRC="{$img_dir}zoom04.png" ALIGN="middle" WIDTH="25" HEIGHT="25" BORDER="0" ALT="Email dit artikel aan vriend(in)"><span class="discount" style="font-size:11px;"> {l s='Email dit artikel aan vriend(in)' mod='sendtoafriend'}</a></li>
          

          How can I remove the second URL part from my URL:
          http://www.tweewielersite.nl/tweewielersite/sendtoafriend-form.php?id_product=http://www.tweewielersite.nl/tweewielersite/102-sparta-e-motion-damesfiets.html

          Can someone help me to fix the code for me please....

          THX from the Netherlands...

            Write a Reply...