|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-01-22 18:38 UTC] mail at requinix dot net
[2014-01-22 18:46 UTC] rasmus@php.net
-Status: Open
+Status: Not a bug
[2014-01-22 18:46 UTC] rasmus@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 14:00:01 2026 UTC |
Description: ------------ You can see all information in the test script. Test script: --------------- $inputArray = array( 'shipping' => array( 'after' => array(), 'before' => array(), '_code' => 'shipping' ), 'freeshipping' => array( 'after' => array(), 'before' => array(), '_code' => 'freeshipping' ), 'discount' => array( 'after' => array('shipping', 'tax_shipping'), 'before' => array(), '_code' => 'discount' ), 'tax_shipping' => array( 'after' => array('shipping'), 'before' => array('discount'), '_code' => 'tax_shipping' ) ); function compare ($a, $b) { $aCode = $a['_code']; $bCode = $b['_code']; if (in_array($aCode, $b['after']) || in_array($bCode, $a['before'])) { $res = -1; } elseif (in_array($bCode, $a['after']) || in_array($aCode, $b['before'])) { $res = 1; } else { $res = 0; } return $res; } uasort($inputArray, 'compare'); var_dump(array_keys($inputArray)); Expected result: ---------------- array (size=4) 0 => string 'shipping' (length=8) 1 => string 'tax_shipping' (length=12) 2 => string 'discount' (length=8) 3 => string 'freeshipping' (length=12) Or another position for 'freeshipping'. But 'shipping' must be before 'tax_shipping' and 'discount' must be after 'tax_shipping'. Actual result: -------------- array (size=4) 0 => string 'tax_shipping' (length=12) 1 => string 'discount' (length=8) 2 => string 'freeshipping' (length=12) 3 => string 'shipping' (length=8)