Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6326019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:00:12+00:00 2026-05-24T17:00:12+00:00

I have this array: array(122) { [1AB168820010]=> array(3) { [MACHINE_NAME]=> L1XP2A [FEEDER_SLOT]=> 114 [REJECT_RATE]=>

  • 0

I have this array:

array(122) { 
    ["1AB168820010"]=> array(3) { 
       ["MACHINE_NAME"]=> "L1XP2A"
       ["FEEDER_SLOT"]=> "114"
       ["REJECT_RATE"]=> float(0.0394) 
       ["DEFECT_QTY"]=> int(2) 
       ["SOLDER BALL"]=> int(2) 
    }  
    ["1AB037870031"]=> array(5) { 
       ["MACHINE_NAME"]=> "L2CP7A"
       ["FEEDER_SLOT"]=> "155"
       ["REJECT_RATE"]=> float(2.3022) 
       ["DEFECT_QTY"]=> int(39) 
       ["COMPONENT TOMBSTONED"]=> int(31) 
       ["SOLDER BALL"]=> int(2) 
       ["COMPONENT BILLBOARD"]=> int(6)
    } 
    ["1AB144890021"]=> array(7) { 
       ["MACHINE_NAME"]=> "L21P3A"
       ["FEEDER_SLOT"]=> "214"
       ["REJECT_RATE"]=> float(0.0225) 
       ["DEFECT_QTY"]=> int(8) 
       ["SOLDER INSUFFICIENT "]=> int(2) 
       ["SOLDER BAD"]=> int(2) 
       ["SOLDER BALL"]=> int(2) 
       ["COMPONENT MISSING"]=> int(1) 
       ["COMPONENT BILLBOARD"]=> int(1) 
    } 
    ["1AB144890033"]=> array(7) {
       ["MACHINE_NAME"]=> "L1CP7A"
       ["FEEDER_SLOT"]=> "234" 
       ["REJECT_RATE"]=> float(0.0142) 
       ["DEFECT_QTY"]=> int(7) 
       ["SOLDER INSUFFICIENT "]=> int(1) 
       ["SOLDER BAD"]=> int(1) 
       ["COMPONENT MISSING"]=> int(3) 
       ["COMPONENT SKEW"]=> int(1) 
       ["COMPONENT TOMBSTONED"]=> int(1) 
    }
    #...more
}

I need to loop through the array and create a string from the array output that looks like this but don’t know the best way…please help

 1AB168820010 ( 0.0394% ) #<-this is the 'REJECT_RATE'
  -Machine: L1XP2A
  -Feeder: 114
     SOLDER BALL ( 100% ) #<-'SOLDER BALL' value (2) divided by 'DEFECT_QTY' (2) * 100
 ------------------------
 1AB037870031 ( 2.3022% ) 
  -Machine: L2CP7A
  -Feeder: 155
     COMPONENT TOMBSTONED ( 79.48% ) #<- ( 31 / 39 ) * 100
     COMPONENT BILLBOARD ( 15.38% )  #<- ( 6 / 39 ) * 100
     SOLDER BALL ( 5.12% ) #<- ( 2 / 39 ) * 100
 ------------------------
 1AB144890021 ( 0.0225% )
  -Machine: L2IP3A
  -Feeder: 214
     SOLDER INSUFFICIENT ( 25% )
     SOLDER BAD ( 25% )
     SOLDER BALL ( 25% )
     COMPONENT MISSING ( 12.5% )
     COMPONENT BILLBOARD ( 12.5% )
 ------------------------
 1AB144890033 ( 0.0142% )
  -Machine: L1CP7A
  -Feeder: 234
     SOLDER INSUFFICIENT ( 14.3% )
     SOLDER BAD ( 14.3% )
     COMPONENT MISSING ( 42.8% )
     COMPONENT SKEWED ( 14.3% )
     COMPONENT TOMBSTONED ( 14.3% )

My main issue I’m not sure how to handle is that I don’t know the number of defects (i.e. COMPONENT MISSING, COMPONENT SKEWED, SOLDER BAD) per partnumber, how many defects (and what defects it has) will vary, therefore I can’t just hard-code ‘COMPONENT MISSING: [some calc]’ into my foreach loop….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:00:14+00:00Added an answer on May 24, 2026 at 5:00 pm

    (Optionally, you can sort the array by its keys: ksort($array);.)

    Next, you iterate over each element and build the string:

    $output = '';
    foreach ($array as $key => $data) {
      $output .= $key . ' ( ' . number_format($data['REJECT_RATE'], 3) . '% )' . "\n";
      $output .= ' -Machine: ' . $data['MACHINE_NAME'] . "\n";
      $output .= ' -Feeder: ' . $data['FEEDER_SLOT'] . "\n";
      $output .= '  SOLDER BALL ( ' . number_format(2 / $data['DEFECT_QTY'] * 100, 0) . '% )'. "\n";
    
      // Add more calculation here…
    
      $output .= "------------------------\n";
    }
    

    And finally, you output the string: echo $output;.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this array, for example (the size is variable): x = [1.111, 1.122,
Lets say I have this array, int[] numbers = {1, 3, 4, 9, 2};
I have this Array i wrote a function MostFreq that takes an array of
I have this array in PHP: array( [0] => array( 'username' => 'user1' )
I have this array: string[,] productData = new string[5,7]; I bind it to a
I have this array: $items_pool = Array ( [0] => Array ( [id] =>
So, I have this array. It needs to be accessed outside the scope of
how i can duplicate one element from array: for example, i have this array:
1) I have this Javascript array: lang=new Array(); lang[sq]=Albanian; lang[ar]=Arabic; lang[en]=English; lang[ro]=Romanian; lang[ru]=Russian; 2)
I have this code: $rows = array(); $res = mysql_query($someQuery); if(!mysql_errno()) while($row = mysql_fetch_assoc($res))

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.