How do i call two parameters for array

Hi,
If I do not know how to do that I would be glad to help
I tried a lot of trial and error but I couldn’t get the result.

// What brands are available for this product
// We have created array of brands of products to search
$brands = array("a","b","c");

//entries of products to be searched
//If the first option is not available look for the next option
$entries = array("10","14","17");

// Floors where the panel is located
// The indexes here represent the block
$panel_floors = array(
    "1" => "18,13,7,3,1",
    "2" => "18,13,7,3,1"
);

// How many shafts are used in the block
// If there are 2 blocks, the products of the block will be multiplied by two.
// The indexes here represent the block 
$number_of_shafts = array(
    "1" => "1",
    "2" => "2" // Since the number of shafts is 2, the products will be doubled
);

// How many switches are there in which block, in which board?
// If it is 1, 10X20, if 2, 10X30, if 3, 10X40 products with input and output will be searched.
// In the example below, the product of the 1st block 18th floor will be searched for 10X30
// In the example below, the product of the 1st block 3th floor will be searched for 10X30
// The indexes here represent the block 
$number_switches_floor = array(
    "1"=>array(
        "18"=>2,"13"=>1,"7"=>1,"3"=>1,"1"=>1
    ),
    "2"=>array(
        "18"=>1,"13"=>1,"7"=>1,"3"=>2,"1"=>1
        )
);

//I'm not sure if it's correct to create an array by pulling all products from the database beforehand
// Note: Not even 100 items, maybe 70-80
$products = array(
    "0"=>['id'=>1,'inputxoutput'=>'10X20','decibel_loss'=>'-20'],
    "1"=>['id'=>2,'inputxoutput'=>'10X20','decibel_loss'=>'-16'],
    "2"=>['id'=>3,'inputxoutput'=>'10X20','decibel_loss'=>'-12'],
    "3"=>['id'=>4,'inputxoutput'=>'10X20','decibel_loss'=>'-08'],
    "4"=>['id'=>5,'inputxoutput'=>'10X30','decibel_loss'=>'-20'],
    "5"=>['id'=>6,'inputxoutput'=>'10X30','decibel_loss'=>'-16'],
    "6"=>['id'=>7,'inputxoutput'=>'10X30','decibel_loss'=>'-12'],
    "7"=>['id'=>8,'inputxoutput'=>'10X30','decibel_loss'=>'-08'],
    "8"=>['id'=>9,'inputxoutput'=>'10X40','decibel_loss'=>'-20'],
    "9"=>['id'=>10,'inputxoutput'=>'10X40','decibel_loss'=>'-16'],
    "10"=>['id'=>11,'inputxoutput'=>'10X40','decibel_loss'=>'-12'],
    "11"=>['id'=>12,'inputxoutput'=>'10X40','decibel_loss'=>'-08']
);


foreach($brands AS $brand){

    foreach($panel_floors AS $block=>$floors){
        $splitter_floors = explode(",", $floors);
        $count_floors = count($splitter_floors);

        if($count_floors == 5){
        // In the example here, if there are 5 panels, it shows how many decibels the product will be searched for which floor.
        // The example is not required for the 1st floor in the system here. because on the 3rd floor it will take and finish
        $target_products = array("18x-20|13x-16|7x-12|3x-08");
        }

    for ($vi = 0; $vi < count($target_products); $vi++) {
    $floor_tapoff = explode("|", $target_products[$vi]);
    $count_product = count($floor_tapoff);

        foreach($floor_tapoff AS $floortapoff){
        $splitter_floor_tapoff = explode("x", $floortapoff);
        $floor = $splitter_floor_tapoff[0]; // Floors 18, 13, 7, 3, 1
        $tapoff =$splitter_floor_tapoff[1]; // product to search -20, -16, -12, -08

        
        } // foreach($floor_tapoff AS $floortapoff){


    } // for ($vi = 0; $vi < count($target_products); $vi++) {
    
} // foreach($panel_floors AS $block=>$floors){

} // foreach($brands AS $brand){;

For brand preference selection, I need to print each brand separately.

I got the result like this but I don’t know how accurate it is
How can I separate brands? To show in separate table
| brand | block | floor | id | input output |

Array
(
    [0] => NEXT-1-18-5-10X30
    [1] => NEXT-1-13-2-10X20
    [2] => NEXT-1-7-3-10X20
    [3] => NEXT-1-3-4-10X20
    [4] => NEXT-2-18-1-10X20
    [5] => NEXT-2-13-2-10X20
    [6] => NEXT-2-7-3-10X20
    [7] => NEXT-2-3-8-10X30
    [8] => TEKNİKSAT-1-18-5-10X30
    [9] => TEKNİKSAT-1-13-2-10X20
    [10] => TEKNİKSAT-1-7-3-10X20
    [11] => TEKNİKSAT-1-3-4-10X20
    [12] => TEKNİKSAT-2-18-1-10X20
    [13] => TEKNİKSAT-2-13-2-10X20
    [14] => TEKNİKSAT-2-7-3-10X20
    [15] => TEKNİKSAT-2-3-8-10X30
)

This is the result I got but the brands are adjacent

// What brands are available for this product
// We have created array of brands of products to search
$brands = array("NEXT","TEKNİKSAT");

//entries of products to be searched
//If the first option is not available look for the next option
$entries = array("10","14","17");

// Floors where the panel is located
// The indexes here represent the block
$panel_floors = array(
    "1" => "18,13,7,3,1",
    "2" => "18,13,7,3,1"
);

// How many shafts are used in the block
// If there are 2 blocks, the products of the block will be multiplied by two.
// The indexes here represent the block 
$number_of_shafts = array(
    "1" => "1",
    "2" => "2" // Since the number of shafts is 2, the products will be doubled
);

// How many switches are there in which block, in which board?
// If it is 1, 10X20, if 2, 10X30, if 3, 10X40 products with input and output will be searched.
// In the example below, the product of the 1st block 18th floor will be searched for 10X30
// In the example below, the product of the 1st block 3th floor will be searched for 10X30
// The indexes here represent the block 
$number_switches_floor = array(
    "1"=>array(
        "18"=>2,"13"=>1,"7"=>1,"3"=>1,"1"=>1
    ),
    "2"=>array(
        "18"=>1,"13"=>1,"7"=>1,"3"=>2,"1"=>1
        )
);


//I'm not sure if it's correct to create an array by pulling all products from the database beforehand
// Note: Not even 100 items, maybe 70-80
$products = array(
    "0"=>['id'=>1,'inputxoutput'=>'10X20','decibel_loss'=>'-20','marka'=>'next'],
    "1"=>['id'=>2,'inputxoutput'=>'10X20','decibel_loss'=>'-16'],
    "2"=>['id'=>3,'inputxoutput'=>'10X20','decibel_loss'=>'-12'],
    "3"=>['id'=>4,'inputxoutput'=>'10X20','decibel_loss'=>'-08'],
    "4"=>['id'=>5,'inputxoutput'=>'10X30','decibel_loss'=>'-20','marka'=>'tekniksat'],
    "5"=>['id'=>6,'inputxoutput'=>'10X30','decibel_loss'=>'-16'],
    "6"=>['id'=>7,'inputxoutput'=>'10X30','decibel_loss'=>'-12'],
    "7"=>['id'=>8,'inputxoutput'=>'10X30','decibel_loss'=>'-08'],
    "8"=>['id'=>9,'inputxoutput'=>'10X40','decibel_loss'=>'-20'],
    "9"=>['id'=>10,'inputxoutput'=>'10X40','decibel_loss'=>'-16'],
    "10"=>['id'=>11,'inputxoutput'=>'10X40','decibel_loss'=>'-12'],
    "11"=>['id'=>12,'inputxoutput'=>'10X40','decibel_loss'=>'-08']
);


function search($array, $search_list) {

    // Create the result array
    $result = array();
  
    // Iterate over each array element
    foreach ($array as $key => $value) {
  
        // Iterate over each search condition
        foreach ($search_list as $k => $v) {
      
            // If the array element does not meet
            // the search condition then continue
            // to the next element
            if (!isset($value[$k]) || $value[$k] != $v)
            {
                  
                // Skip two loops
                continue 2;
            }
        }
      
        // Append array element's key to the
        //result array
        $result[] = $value['id'];
    }
  
    // Return result 
    return $result;
}


foreach($brands AS $brand){

    foreach($panel_floors AS $block=>$floors){
        $splitter_floors = explode(",", $floors);
        $count_floors = count($splitter_floors);

        if($count_floors == 5){
        // In the example here, if there are 5 panels, it shows how many decibels the product will be searched for which floor.
        // The example is not required for the 1st floor in the system here. because on the 3rd floor it will take and finish
        $target_products = array("18x-20|13x-16|7x-12|3x-08");
        }

    for ($vi = 0; $vi < count($target_products); $vi++) {
    $floor_tapoff = explode("|", $target_products[$vi]);
    $count_product = count($floor_tapoff);

        foreach($floor_tapoff AS $floortapoff){
            $splitter_floor_tapoff = explode("x", $floortapoff);
            $floor = $splitter_floor_tapoff[0]; // Floors 18, 13, 7, 3, 1
            $tapoff =$splitter_floor_tapoff[1]; // product to search -20, -16, -12, -08

            // Is the switch 1, 2, 3 or more?
            $count_switch = $number_switches_floor[$block];

        // search by number of switches
        if($count_switch[$floor] == 1){
            $search_items = array('decibel_loss'=>$tapoff, 'inputxoutput'=>"10X20");
            $display_in_array = "10X20";
        }elseif($count_switch[$floor] == 2){
            $search_items = array('decibel_loss'=>$tapoff, 'inputxoutput'=>"10X30");
            $display_in_array = "10X30";
        }elseif($count_switch[$floor] == 3){
            $search_items = array('decibel_loss'=>$tapoff, 'inputxoutput'=>"10X40");
            $display_in_array = "10X40";
        }elseif($count_switch[$floor] > 3){
            $search_items = array('decibel_loss'=>$tapoff, 'inputxoutput'=>"10X40");
            $display_in_array = "10X40";
        }

            // Define search list with multiple key=>value pair
            // Search in array from above function
            $res = search($products, $search_items);

            // To add which block and which floor information to the found product IDs
            foreach($res AS $vaa){
                $founds[] = $brand."-".$block."-".$floor."-".$vaa."-".$display_in_array;
            }

        } // foreach($floor_tapoff AS $floortapoff){

    } // for ($vi = 0; $vi < count($target_products); $vi++) {
    
} // foreach($panel_floors AS $block=>$floors){

} // foreach($brands AS $brand){

echo '<pre>' . print_r($founds, true) . '</pre>';
Sponsor our Newsletter | Privacy Policy | Terms of Service