Announcement

Collapse
No announcement yet.

php experts!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    php experts!

    Hi,

    Is it possible in php to split a sentance into different words and then add some html to before/after each word?

    e.g. I have the following text in a variable:

    "Acrylic Flower Vase Block Square"

    I want to break the sentance into its component words, e.g.

    Acrylic
    Flower
    Vase
    Block
    Square

    I want to then wrap a <a> around them linking to the search script so that each one can be searched on.

    any ideas?

    Thanks,
    Paul.

    #2
    Look in the Advanced guide for the article on truncating the product description after 10 words. That'll give you some ideas.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      thanks norman, worked great. for anyone else searching:

      Code:
      <actinic:block php="true" >
      $sShort = "";
      $sOriginal = '<actinic:variable name="Prod_All_Keywords" />'; 
      foreach(explode(" ", $sOriginal) as $sWord)
      {
      $sShort .= " <a href='http://www.madmash.com/cgi-bin/ss002207.pl?page=search&SS=" .  sWord . "&PR=-1&TB=A'>" . $sWord . "</a> ";
      }
      echo $sShort;
      </actinic:block>
      Prod_All_keywords is my list of search terms...

      thanks,
      Paul.

      Comment


        #4
        I'd change

        $sOriginal = '<actinic:variable name="Prod_All_Keywords" />';

        to

        $sOriginal = '<actinic:variable name="Prod_All_Keywords" encoding="perl" />';

        just in case there's ever any single quotes in your keywords.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          updated. thanks for the advice.

          Paul.

          Comment

          Working...
          X