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 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2006
    Posts
    29
    Thanks
    7
    Thanked 0 Times in 0 Posts

    replace space with  

    Hi, all.

    Just a quick question: is there a PHP function that allows me to replace a blank space with  ?

    For example...

    Code:
    This is an example sentence with blank spaces between words.
    into this:

    Code:
    This is an example sentence with blank spaces between words.
    Thanks!

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Code:
    $str="This is an example sentence with blank spaces between words.";
    echo str_replace(' ',' ',$str);
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    abcdefGARY (05-23-2008)

  • #3
    Regular Coder
    Join Date
    Sep 2006
    Location
    Vermont, USA
    Posts
    154
    Thanks
    0
    Thanked 6 Times in 6 Posts
    I realize you didnt ask about this, but it seems like you're trying to stop a line from breaking. If this is the case... you might want to use
    Code:
    <style>
    .nowrap { 
    white-space: nowrap;
    }
    </style>
    <p class="nowrap">This is an example sentence with blank spaces between words.</p>
    Thanks abduraooft
    Last edited by syosoft; 05-22-2008 at 11:22 AM. Reason: stupidy.
    Active PHP/MySQL application developer available for immediate work.
    syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Quote Originally Posted by syosoft
    <style>
    .nowrap {
    white: nowrap;
    }
    </style>
    white-space ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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