[PHP] strip comma from $value

2003-02-28 Thread Jim Long
Hi,

I've figured out the way to solve my problem is to get rid of the commas
before I sort.

Trying to use this:

//strip the commas---
foreach ($numeric_array as $key = $value) {
if (stristr($value, ,)){
//test to see if it worked
echo(comma striped); 
}
}

-- 

It passed the test but,
I'm doing something wrong because the commas are still there.

TIA,
Jim Long

Jim Long Wrote:
 Does anyone know how to make the flag sort_numeric work? 
 Will it work with asort?  
 
 asort ($numeric_array, SORT_NUMERIC);
 I've tried this but it looks like it's having problems with the comma in
 big numbers. 
 I'm not absolutely sure, but it looks like it's ignoring everything
 after a comma when it sorts.
 


 
 BTW: asort is the one I need as I must maintain the keys
 
 JanetVal Wrote:
 
  sort() sorts by value but assigns new keys as numbers.
  asort() sorts by value, but keeps the same keys
  ksort() sorts by key.
 
 THANKS !

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strip comma from $value

2003-02-28 Thread Hugh Danaher
try ereg_replace(,,,$value);

- Original Message -
From: Jim Long [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, February 28, 2003 9:17 AM
Subject: [PHP] strip comma from $value


 Hi,

 I've figured out the way to solve my problem is to get rid of the commas
 before I sort.

 Trying to use this:

 //strip the commas---
 foreach ($numeric_array as $key = $value) {
 if (stristr($value, ,)){
 //test to see if it worked
 echo(comma striped);
 }
 }

 --

 It passed the test but,
 I'm doing something wrong because the commas are still there.

 TIA,
 Jim Long

 Jim Long Wrote:
  Does anyone know how to make the flag sort_numeric work?
  Will it work with asort?
 
  asort ($numeric_array, SORT_NUMERIC);
  I've tried this but it looks like it's having problems with the comma in
  big numbers.
  I'm not absolutely sure, but it looks like it's ignoring everything
  after a comma when it sorts.
 


 
  BTW: asort is the one I need as I must maintain the keys
 
  JanetVal Wrote:
 
   sort() sorts by value but assigns new keys as numbers.
   asort() sorts by value, but keeps the same keys
   ksort() sorts by key.
 
  THANKS !

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strip comma from $value

2003-02-28 Thread Justin French
on 01/03/03 4:41 AM, Hugh Danaher ([EMAIL PROTECTED]) wrote:

 try ereg_replace(,,,$value);

no need for ereg here...

str_replace(',','',$value);

:)

justin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php