Array merge sorting problems

Source: Internet
Author: User
This post was last edited by lazygc520 on 2013-06-07 09:37:32

 
  $row 2[0], ' count ' = $row 2[1]);} Print_r ($var);} echo $a [$k] [' 5 ']. '
';? >


The results obtained:

Array ([0] = = Array ([Lotno] = 3207 [count] = +)) array ([0] = =            Array ([Lotno] = 3207 [count] = +)) array ([0] = = Array (            [Lotno] = 3206 [Count] [1] = = Array ([Lotno] + 3207 [Count] = 3)) array ([0] = = Array ([Lotno] = 3207 [Count] =&gt ;    ) array ([0] = = Array ([Lotno] = 3207 [count] = +)) Array (        [0] = = Array ([Lotno] = 3218 [count] = +)) array ([0] = = Array ([Lotno] = 3218 [Count] = 15)) Array ([0] = = Array ([Lotno] = 3218 [count] = +)) array ([0] = = Array ([Lotno] = 3218 [count] = =) array ([0] = = Array ([Lotno] = 3218 [count] = +)) Array (        [0] = = Array ([Lotno] = 3218 [count] = +)) array ([0] = = Array ([Lotno] = 3218 [Count] = 15)) Array ([0] = = Array ([Lotno] = 3218 [count] = +)) array ([0] = =            Array ([Lotno] = 3218 [count] = +)) array ([0] = = Array ( [Lotno] = 3218 [Count] = ()) array ([0] = = Array ([lotno] = = 3218 [Count] = ()) array ([0] = = Array ([Lotno] = 3218 [cou NT] = 15))

How do you combine these two-dimensional arrays into an array and sort by lotno?
If the Lotno phase is the same, the value corresponding to count is added. May I ask how to deal with it?


Reply to discussion (solution)

$sql = "Select DISTINCT b.packageno,a.stock_no from ' Stock_detail ' as a, ' kw_manage ' as B where a.stock_no = '". $stockno. " ' And a.cust_no = replace (b.cust_no, ' ', ') '; $result = mysql_query ($sql); $res = Array (); Sets an array to hold the result ($row = Mysql_fetch_array ($result, Mysql_assoc)) {    $sql 2 = "Select Lotno,count (Lotno) from ' Vp_ Barcode_2d_y ' Where Packageno = ' ". $row [' Packageno ']. ' GROUP by Lotno ORDER by lotno ASC ';    $result 2 = mysql_query ($sql 2);    $var = Array ();    while ($row 2 = mysql_fetch_array ($result 2,mysql_num))    {       if (isset ($res [$row 2[0])) $res [$row 2[0]][' count '] + = $row 2[1];       else $res [$row 2[0]] = Array (' lotno ' = = $row 2[0], ' count ' = $row 2[1]);}    } Ksort ($res); Because the key name has been processed into a Lotno value, the key name sort is sorted by Lotno
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.