This is a discussion on another newbie question! :) within the PHP Language forums, part of the PHP Programming Forums category; Hi there again.. i also was wondering about replacing variables in a script. say i have something that calls up: ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi there again.. i also was wondering about replacing variables in a
script. say i have something that calls up: 1558 chestnut ave. how would i change the spaces to + like: 1558+chestnut+ave i would be calling it up from a sql database. then posting it with an echo function like: echo('<font size="2" face="Arial, Helvetica, sans-serif"><b>' . $row['company'] . '</b>' . '<br>' . $row['address'] . '<br>' ..$row['city'] . ' ' . $row['state'] . ', ' . $row['zip'] . '<br>' . '<a href="http://' . $row['website'] . '">' . $row['website'] . '</a>' . '<br>' . $row['description'] . '</font></li></p>'); and the address would be the one i need changed. Thanks so much again for the direction! |
|
|||
|
Mikey P wrote:
> Hi there again.. i also was wondering about replacing variables in a > script. > > say i have something that calls up: > > 1558 chestnut ave. > > how would i change the spaces to + like: > > 1558+chestnut+ave > > > i would be calling it up from a sql database. then posting it with an > echo function like: > > echo('<font size="2" face="Arial, Helvetica, sans-serif"><b>' . > $row['company'] . '</b>' . '<br>' . $row['address'] . '<br>' > .$row['city'] . ' ' . $row['state'] . ', ' . $row['zip'] . '<br>' . > '<a href="http://' . $row['website'] . '">' . $row['website'] . > '</a>' . '<br>' . $row['description'] . '</font></li></p>'); > > and the address would be the one i need changed. > > Thanks so much again for the direction! At first glance str_replace() would be the most efficient manner, however you may also be after urlencode() depending what else you plan to do with the string. -- Logical |
|
|||
|
Mikey P wrote:
> Hi there again.. i also was wondering about replacing variables in a > script. > > say i have something that calls up: > > 1558 chestnut ave. > > how would i change the spaces to + like: > > 1558+chestnut+ave http://ch.php.net/manual/en/function.str-replace.php ? Aphrael... -- "La demande mondiale d’ordinateurs n’excédera pas cinq machines." (Thomas Watson, Fondateur d'IBM, 1945) |