Announcement

Collapse
No announcement yet.

shorten product description

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

    shorten product description

    Ok I am trying to make a shortend down version of a product description to put on my sections. So far I have this.

    Code:
    <actinic:block php="true" >
    $desc = '<actinic:variable encoding="perl" name="ProductDescription" selectable="false" />';
      
    $desc1 = substr($desc, 3,150);
    
    echo "$desc1....";
    
      
    </actinic:block>
    this works fine and generated 150 letters however it never finishes on the last word it finishes half way through a word. Does anyone know how I can make it finish off the word then end


    Solution,


    Code:
    <actinic:block php="true" >
    $desc = '<actinic:variable encoding="perl" name="ProductDescription" selectable="false" />';
      
    $desc1 = explode(substr($desc, 3,150));
    
    echo "$desc1....";
    
      
    </actinic:block>
    www.simonstaton.co.uk

    #2
    Explode it!
    http://uk3.php.net/explode
    "If my answers frighten you then you should cease asking scary questions"

    Comment


      #3
      Find the position of the next or previous space (whitespace) in the string from 180 characters onwards and use everything to the left of that position.

      Comment


        #4
        ok cheers ive got it
        www.simonstaton.co.uk

        Comment


          #5
          If you provide the solution in here, sure it will help others searching in the future and means you can give something back to the community also, win win for all.

          Comment


            #6
            ok will do in a post edit
            www.simonstaton.co.uk

            Comment

            Working...
            X