Results 1 to 1 of 1

Thread: Creeping Spaces

  1. #1
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    286
    Thanks
    95
    Thanked 3 Times in 3 Posts

    Default Creeping Spaces

    This query relates to the same code at issue in the recent thread "To Code a Line Break":

    John provided suggested code that solved the problem completely:
    PHP Code:
    echo "Comment of former client" $testitable [$element] . "(file " rtrim($testitable [$element 1]) . "):  “" trim(preg_replace('"<br />[\x0d\x0a]*<br />[\x0d\x0a]*"'"<br />\n<br />\n“"$testitable [$element 2])) ."”&nbsp;&nbsp;<br /><br />[For comments of other former clients, see our <a href='testimonials.php'>testimonials </a> page.]<br />";    // display accolade. 
    In an effort to simplify, I tried to do the same thing using str_replace in lieu of preg_replace:
    PHP Code:
    echo "Comment of former client" $testitable [$element] . "(file " $testitable [$element 1] . "): “" str_replace("<br />\x0d\x0a<br />""<br />\x0d\x0a<br />“"trim($testitable [$element 2])) . "”<br /><br />[For comments of other former clients, see our <a href='testimonials.php'>testimonials </a> page.]<br /><br />"
    My replacement code works, almost. The "almost" is that the replacement code causes insertion of an unwanted space immediately following insertion of quotation mark in all new paragraphs.

    I am at a loss to see from where those unwanted spaces creep.

    A.
    Last edited by marain; 12-23-2014 at 01:58 PM. Reason: Reposition "trim" to immediately precede ($testitable [$element + 2])

Similar Threads

  1. spaces
    By d-machine in forum PHP
    Replies: 1
    Last Post: 06-19-2010, 05:10 PM
  2. Only Letters and Spaces
    By MrSheen in forum PHP
    Replies: 4
    Last Post: 07-27-2007, 10:32 AM
  3. These spaces...
    By alexjewell in forum HTML
    Replies: 7
    Last Post: 09-17-2006, 07:51 PM
  4. spaces between images in FF and IE
    By derlagen in forum HTML
    Replies: 1
    Last Post: 07-18-2006, 04:31 AM
  5. Get rid of spaces between Tabs
    By mclark2112 in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 07-10-2006, 03:55 PM

Bookmarks

Posting Permissions

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