V
V
Valentine52020-08-26 18:20:33
PHP
Valentine5, 2020-08-26 18:20:33

How to fix output from an array on the front-end if sorting functions do not work?

Hello dear experts!

There is an incorrect display of information on the site:

5f467a9752cec830878575.png

The amount of the share precedes the name of the parent company.

This output is given by the following code:

$history_fns = [];
$xq = 0;
/* $history_fns['Совладельцы'][$value1[grn_date]][delete][$xq] */

foreach ($history_egrul[data] as $key => $value) { 
                                  foreach ($value[changes] as $key1=> $value1) {
                           if($value1[title][value]=='uchr_dol' || $value1[title][value]=='uchr') {
                               $history_fns['Совладельцы'][$value1[grn_date]][delete][$xq] = $value1[val_old];
                                $history_fns['Совладельцы'][$value1[grn_date]][add][$xq] = $value1[val_new];

                         }

                                 if($value1[title][value]=='ruk') {
                           $history_fns['Руководитель'][$value1[grn_date]][delete][$xq] = $value1[val_old];
                                /* var_dump($history_fns['Руководитель'][$value1[grn_date]][delete][$xq]); */
                            $history_fns['Руководитель'][$value1[grn_date]][add][$xq] = $value1[val_new];

                         }

                                  if($value1[title][value]=='addr') {
                           $history_fns['Адрес'][$value1[grn_date]][delete][$xq] = $value1[val_old];   
                            $history_fns['Адрес'][$value1[grn_date]][add][$xq] = $value1[val_new];

                         }

                         if($value1[title][value]=='okved') {
                           $history_fns['Основной вид деятельности'][$value1[grn_date]][delete][$xq] = $value1[val_old];   
                            $history_fns['Основной вид деятельности'][$value1[grn_date]][add][$xq] = $value1[val_new];

                         }

                                   if($value1[title][value]=='uchr_inn') {
                           $history_fns['ИНН совладельцев'][$value1[grn_date]][delete][$xq] = $value1[val_old];   
                            $history_fns['ИНН совладельцев'][$value1[grn_date]][add][$xq] = $value1[val_new];

                         }

                                   if($value1[title][value]=='Usumma') {
                          if($value1[val_old][0][value]!=0) {$history_fns['Доля организации'][$value1[grn_date]][delete][$xq] = $value1[val_old];   }
                           if($value1[val_new][0][value]!=0) { $history_fns['Доля организации'][$value1[grn_date]][add][$xq] = $value1[val_new];   }
                         }

                         $xq++;
                     //   echo "<br><br>";
                        var_dump($history_fns);              
                     }


                  } // print_r($history_egrul);
/* $s = array_reverse($history_fns);
var_dump($s); */
var_dump($history_fns);
               //   print_r($history_egrul);         
                                    if($history_fns) {    

                 ?>

                       <div class="egrul-content-tab <?=$fns_class?>" id="egrul-tab-content-1">
                      <div class="table">
                        <div class="table-body fns">

                            <?php      $t = 0; $hide = '';                  foreach ($history_fns as $key => $value) {
                                    $t++;    if($t>3) {$hide = ' style="display:none;"'; $show_button = 1;}

                                ?>
                          <div class="table-row" <?=$hide?>>

                            <div class="title">
                              <h3><?=$key?></h3>
                            </div> 
                              <?php foreach ($value as $key1 => $value1) { ?>
                            <div class="table-row-inner">
                              <div class="table-col date">
                                  <span><?=date("d.m.Y", strtotime($key1));?></span>
                              </div>
                              <div class="table-col info-old">

                                  <div class="item">
                                      <?php

                                        foreach ($value1[delete] as $key2 => $value2) {

                                        foreach ($value2 as $key3 => $value3) {
                                            $change_t=$change_v = '';

                                            if(is_array($value3)) {
                                              //  echo "<br><br>";
                                               // print_r($value1[delete]);
                                               // echo "<br><br>";
                                               //   print_r($value1[add]);
                                                if($value1[delete][$key2][$key3][header]!=$value1[add][$key2][$key3][header]) {$change_t =  ' class="rename"';} 
                                                if($value1[delete][$key2][$key3][value]!=$value1[add][$key2][$key3][value]) {$change_v =  '<span'.' class="rename">';} 
                                              //  echo $value[$key1][delete][$key2][$key3][title].'!='.$value[$key1][add][$key2][$key3][title];
                                       echo '<p style="word-break: break-word;">'; if($value3[header]!='Должность:' && $value3[header]) {echo '<span'.$change_t.'>'; echo Users::DemoHide($value3[header],$demo , 5) ;  echo '</span>';}    
                                            arsort($value3[value]);
                                            echo $change_v.Users::DemoHide($value3[value],$demo , 3 );
                                            if($value1[delete][$key2][$key3][value]!=$value1[add][$key2][$key3][value]) { echo '</span>'; }
                                     if($key=='Руководитель' && !$value3[header])    {   echo '<span class="icon-name"></span>'; }
                                            echo '</p>'; 
                                          } }
     }?>                


                                </div>


                              </div>
                              <div class="table-col info">

                                     <div class="item">
                                      <?php foreach ($value1[add] as $key2 => $value2) {
                                          foreach ($value2 as $key3 => $value3) {
                                                if(is_array($value3)) {
                                            echo '<p>'; if($value3[header]!='Должность:' && $value3[header]) {echo '<span>'; echo Users::DemoHide($value3[header],$demo , 5) ;  echo '</span>';}
                                             echo Users::DemoHide($value3[value],$demo,3);
                                           if($key=='Руководитель' && !$value3[header])    {   echo '<span class="icon-name"></span>'; }
                                     //   if($value3[title]) {    echo '</span>'; }
                                            echo '</p>'; 
                                          } }}?> 



                                </div>

                              </div>
                            </div>
                              <?php } ?>

                          </div>
                            <?php } ?>


Can you tell me how to fix the code so that the display is correct?

I noticed that the array in the $history_fns variable in the middle of the code changes the order of the array, which is then displayed on the frontend. If you try to flip the array back using the arsort() or sort() function, then the display of information either disappears completely, or nothing happens.. Tell me, please, what could be the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question