FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Syntax for trim charlist?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Syntax for trim charlist? [message #171939 is a reply to message #171937] Sat, 22 January 2011 01:52 Go to previous messageGo to previous message
GarryJones is currently offline  GarryJones
Messages: 21
Registered: September 2010
Karma:
Junior Member
> $source = preg_replace("/[#*]+/g","",$source);
> // $source is replaced with filtered $source

I can't get this example to work.

$source = "garry *** ";
$source = preg_replace("/[#*]+/g","",$source);

print $source;

.....returns an empty string

I need to remove all the * and all the # from the string.

In the records the * and the # are entered after names, sometimes with
a following space

Example of records that are to be treated with this script...

record 1 "Garry ### "
record 2 "John * "
record 3 "Anna ********"
record 4 "Fred **#*###**"

ie, it can be any number of * and # and they can be followed by a
space or not.

I intend to treat every record one by one within a "WHILE", I know how
to that....

For the above I need the output...
"Garry"
"John"
"Anna"
"Fred"

Hope I have explained this better now....

I think I can use "trim" as in $mytrim2 = trim($mytrim1, $charlist);"

And that what I need to do is to declare the variable "$charlist" so
it trims all * and # but I am stuck on how to set $charlist

Garry Jones
Sweden
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Implement Php performace
Next Topic: Is there any situation where anything other than require_once is better?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 18:48:31 GMT 2024

Total time taken to generate the page: 0.05105 seconds