Jump to content

Problem with numbers arragement, decimal appear before single ones


kopromad

Recommended Posts

Hello. I have a problem

 

I am the Data Entry Operator for this website: http://starforce.bg/?UILanguage=EN (I am giving you the English version on purpose).

 

The problem is that products with numbers at the end do not appear in order. For example in "Ammunition, pellets -> Shotshells and buckshots" products arrange in the following order: 1MB Light 30g N10; 1MB Light 30g N11; 1MB Light 30g N7; 1MB Light 30g N8; 1MB Light 30g N9

 

So they go like 10,11,7,8,9 not 7,8,9,10,11

 

It arranges them the right way if I type them with 07,08,09,10,11. Unfortunately I cannot write them like that. Any idea what exactly to search for in the php files. What kind of line exactly.

 

Thank you

use natsort() EG

 


$products = array (
	    '1MB Light 30g N10',
	    '1MB Light 30g N11',
	    '1MB Light 30g N7',
	    '1MB Light 30g N8',
	    '1MB Light 30g N9'
	    );

natsort($products);

echo '<pre>'.print_r($products, 1).'</pre>';

RESULTS:

Array
(
   [2] => 1MB Light 30g N7
   [3] => 1MB Light 30g N8
   [4] => 1MB Light 30g N9
   [0] => 1MB Light 30g N10
   [1] => 1MB Light 30g N11
)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.