Hi,

Thanks to those who have helped me.

Jason Lange Wrote:
> Try this code (tested):
> 
> <---------- Begin Code ---------->
> foreach ($list as $key => $value) {
>      // If elements value is a numeral add to numeric_array
>      if (is_numeric($value)) {
>          $numeric_array[$key] = $value;
>      // If value is not a numeral (presumably 'n/a') add to na_array
>      } else {
>          $na_array [$key] = $value;
>      }
> }
> 
> // Re-combine arrays placing all "other" values at the end
> $final_array = array_merge($numeric_array, $na_array);
> <---------- End Code ---------->

This works.. THANKS!  HOWEVER:

I think PHP is seeing a comma, in a large number and think that it IS
NOT NUMERIC, because when I test a large number it put it in the $na_array

Do I need to add something to this code to stip the commas?

THANKS IN ADAVANCE AGAIN,
Jim Long


Kevin Stone wrote:
> To append my own answer.  In order to sort the non "n/a" values you're going
> to have to build a separate array and perhaps this will simplfy the problem.
> So instead of what I suggested below.. loop the array and start TWO new
> arrays within the loop.  One array for "n/a" values and one for non-"n/a"
> values.  After the values are sorted to their separate arrays do
> asort($nonnavals); then concatonate the two arrays together using
> array_merge(), putting the "n/a" array second.
> 
> - Kevin
> 
> ----- Original Message -----
> From: "Kevin Stone" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Thursday, February 27, 2003 12:04 PM
> Subject: Re: [PHP] restating plea for help with sort
> 
> 
> 
>>Hmm well upon first glance looks like all you need to do is loop that
> 
> array
> 
>>and start a new array within the loop.  An If/Else construct checks If the
>>value is "n/a" then append to the back of the new array Else prepend to
> 
> the
> 
>>front of the new array.    You append the values manually or use
>>array_push() and array_unshift().  Search the manual for more information.
>>Hope that helps.
>>- Kevin
>>
>>----- Original Message -----
>>From: "Jim Long" <[EMAIL PROTECTED]>
>>To: <[EMAIL PROTECTED]>
>>Sent: Thursday, February 27, 2003 11:35 AM
>>Subject: [PHP] restating plea for help with sort
>>
>>
>>
>>>Hi,
>>>
>>>I have an array with an html link as key and different $vars as val:
>>>
>>>$list = array (
>>>'<a href="http://someplace.com/";>some place</a>' => $vendor1_total,
>>>'<a href="http://anotherplace.com/";>another place</a>' =>
> 
> $vendor2__total,
> 
>>>[snip] etc..
>>>
>>>some vals are numeric and some vals are "n/a"
>>>asort works to sort the array as a string, however, I need to sort the
>>>numeric vals numeric, then have the n/a's go away or be output at the
>>>bottom of the sort.
>>>
>>>Please be clear and gentle.. I'm not schooled in php, just a tinkerer
>>>trying to make this mess work.
>>>
>>>Thanks In Advance,
>>>
>>>Jim Long

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

Reply via email to