Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Clip Variable

  1. #1
    Regular Coder
    Join Date
    Oct 2006
    Posts
    197
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Clip Variable

    Im using a PHP variable to define a span tag. However, the spaces in the php varaible seem to be causing problems with the span tag, so I was wondering if anyone can tell me a way to clip the variable down to the first 3 letters and use that.

    For example, variable1=HELLO WORLD, variable2=HEL

    Here is my HTML:

    Code:
            <a href="#" class="buttonx"><span class="<?php echo $_product->gettesting() ?>">This item is <?php echo $_product->gettesting() ?></span></a>
    Can someone explain to me in idiot proof steps what I need to do?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Oct 2006
    Posts
    197
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Does this create a new variable, or remove characters from the same variable?

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Please read the friendly manual pages.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    it does both depending on what you want to use it for

    PHP Code:
    $newvar substr($oldvar0,3); // Creates a new variable $newvar and assigns it to that
    $oldvar substr($oldvar0,3); // Changes the old variable $oldvar to the three letters 
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •