Delete spaces from variabele

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • InSeCo

    #1

    Delete spaces from variabele

    Hello,

    How can you delete spaces within a variabele (php4)?

    $var = "This is an example variabele."

    To :

    $var = "Thisisanexampl evariabele."



  • Scriptdude

    #2
    Re: Delete spaces from variabele

    InSeCo wrote:[color=blue]
    > Hello,
    >
    > How can you delete spaces within a variabele (php4)?
    >
    > $var = "This is an example variabele."
    >
    > To :
    >
    > $var = "Thisisanexampl evariabele."
    >
    >
    >[/color]

    Simple.

    $var = str_replace(" ", "", $var);

    --
    Computers will never take the place of books. You can't stand on a
    floppy disk to reach a high shelf.
    I thought 'Deep Throat' was a movie about a giraffe :/

    Comment

    • Daniel C. Bastos

      #3
      Re: Delete spaces from variabele

      In article <115sif32u8vjb6 8@corp.supernew s.com>, Scriptdude wrote:[color=blue]
      > InSeCo wrote:[color=green]
      >> Hello,
      >>
      >> How can you delete spaces within a variabele (php4)?
      >>
      >> $var = "This is an example variabele."
      >>
      >> To :
      >>
      >> $var = "Thisisanexampl evariabele."
      >>[/color]
      >
      > Simple.
      >
      > $var = str_replace(" ", "", $var);[/color]

      It's a bit better if $var = str_replace(' ', '', $var) since
      double quotes will result in an unnecessary parsing. Right?

      Comment

      • Scriptdude

        #4
        Re: Delete spaces from variabele

        Daniel C. Bastos wrote:
        [color=blue]
        > It's a bit better if $var = str_replace(' ', '', $var) since
        > double quotes will result in an unnecessary parsing. Right?[/color]

        True.

        --
        Computers will never take the place of books. You can't stand on a
        floppy disk to reach a high shelf.
        I thought 'Deep Throat' was a movie about a giraffe :/

        Comment

        Working...