homepage Welcome to WebmasterWorld Guest from 54.224.75.101
register, login, search, subscribe, help, library, PubCon, announcements, recent posts, open posts,
Accredited PayPal World Seller

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library : Charter : Moderators: coopster & eelixduppy & jatar k

PHP Server Side Scripting Forum

    
[Easy] Please help what is the right replacement code
basketmen




msg:4487889
 5:54 am on Aug 24, 2012 (gmt 0)

I have a variable, lets say $peoplename, that have dynamic output

for example

 bryant


or

michael 




like you see, sometime there is   characther in the output, i want to replace that character in the output, please help what is looks like the right replacement code, this should be easy enough, already tried this but its looks like still not right


$nbsp =  ;
$peoplenamereplaced = str_replace($peoplename, $nbsp, $peoplenamereplaced);

 

omoutop




msg:4487894
 6:15 am on Aug 24, 2012 (gmt 0)

if your special characters is only a space, you can use trim() also

phranque




msg:4487920
 9:21 am on Aug 24, 2012 (gmt 0)

i think you are trying to do a string assignment there.

A string literal can be specified in four different ways:
http://php.net/manual/en/language.types.string.php [php.net]

cffrost2




msg:4488059
 5:24 pm on Aug 24, 2012 (gmt 0)

Hi. Try this.

$peoplename = 'Michael ';
$nbsp = ' ';
$peoplnamereplaced = preg_replace('/'.$nbsp.'/', '', $peoplename);
echo $peoplenamereplaced;


Hope this helps.

jadebox




msg:4488091
 7:27 pm on Aug 24, 2012 (gmt 0)

$nbsp = ' ';
$peoplenamereplaced = str_replace($nbsp, '', $peoplenamereplace);

-- Roger

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
WebmasterWorld ® and PubCon ® are a Registered Trademarks of Pubcon Inc.
© Pubcon Inc. 1996-2012 all rights reserved