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

Link to comment
Share on other sites

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
)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.