string replace

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

    string replace

    hi all i need to replace a space in a string of code... basically when
    it creates this link it calls up the state name Like "New Mexico", how
    would i replace the space in New Mexico making it newmexico. my code
    is below.

    <a href="<?php echo(urlencode( $_GET['state2']));?>/<?php
    echo(urlencode( $_GET['city2']));?>main.php?s tate2=<?php
    echo(urlencode( $_GET['state2']));?>&city2=<?p hp
    echo(urlencode( $_GET['city2']));?>"></a>
  • Ian.H

    #2
    Re: string replace

    On Mon, 16 Aug 2004 09:10:40 -0700, Mikey P wrote:
    [color=blue]
    > hi all i need to replace a space in a string of code... basically when
    > it creates this link it calls up the state name Like "New Mexico", how
    > would i replace the space in New Mexico making it newmexico. my code
    > is below.
    >
    > <a href="<?php echo(urlencode( $_GET['state2']));?>/<?php
    > echo(urlencode( $_GET['city2']));?>main.php?s tate2=<?php
    > echo(urlencode( $_GET['state2']));?>&city2=<?p hp
    > echo(urlencode( $_GET['city2']));?>"></a>[/color]


    $foo = str_replace(' ', '', $foo);


    Please read php.net before asking the most basic of questions _easily_
    answered with a bit of 'S E L F I N I T I T A V E!'.

    You'll be wanting to be spoon fed next [sigh].



    Regards,

    Ian

    --
    Ian.H
    digiServ Network
    London, UK


    Comment

    • Jari Lehtinen

      #3
      Re: string replace

      On 16 Aug 2004 09:10:40 -0700, Mikey P <phatnugs420@co mcast.net> wrote:
      [color=blue]
      > hi all i need to replace a space in a string of code... basically when
      > it creates this link it calls up the state name Like "New Mexico", how
      > would i replace the space in New Mexico making it newmexico. my code
      > is below.
      >
      > <a href="<?php echo(urlencode( $_GET['state2']));?>/<?php
      > echo(urlencode( $_GET['city2']));?>main.php?s tate2=<?php
      > echo(urlencode( $_GET['state2']));?>&city2=<?p hp
      > echo(urlencode( $_GET['city2']));?>"></a>[/color]

      Don't know which variable you need to strip the space from but for startes
      have a look at:
      Replace all occurrences of the search string with the replacement string


      --
      Jari Lehtinen

      Comment

      • Chung Leong

        #4
        Re: string replace

        "Ian.H" <ian@WINDOZEdig iserv.net> wrote in message
        news:pan.2004.0 8.16.17.16.27.9 06000@bubbleboy .digiserv.net.. .[color=blue]
        > On Mon, 16 Aug 2004 09:10:40 -0700, Mikey P wrote:
        >[color=green]
        > > hi all i need to replace a space in a string of code... basically when
        > > it creates this link it calls up the state name Like "New Mexico", how
        > > would i replace the space in New Mexico making it newmexico. my code
        > > is below.
        > >
        > > <a href="<?php echo(urlencode( $_GET['state2']));?>/<?php
        > > echo(urlencode( $_GET['city2']));?>main.php?s tate2=<?php
        > > echo(urlencode( $_GET['state2']));?>&city2=<?p hp
        > > echo(urlencode( $_GET['city2']));?>"></a>[/color]
        >
        >
        > $foo = str_replace(' ', '', $foo);
        >
        >
        > Please read php.net before asking the most basic of questions _easily_
        > answered with a bit of 'S E L F I N I T I T A V E!'.
        >
        > You'll be wanting to be spoon fed next [sigh].[/color]

        I'm trying to declare a variable named 'foo'. Can anyone help me?


        Comment

        • Michael Fesser

          #5
          Re: string replace

          .oO(Chung Leong)
          [color=blue]
          >I'm trying to declare a variable named 'foo'. Can anyone help me?[/color]

          class TVar {
          static function create($name) {
          $GLOBALS[$name] = '';
          }
          }

          TVar::create('f oo');

          SCNR
          Micha

          Comment

          Working...