D
D
Dark_Dante2015-05-08 16:19:49
CodeIgniter
Dark_Dante, 2015-05-08 16:19:49

Problem with foreach. Why is it throwing a 504 error?

Hello. Tell me please, who can come across ...
In general, the situation is this. There is a two-dimensional array $a. It contains arrays with data (65 arrays). These data are relatively few, about 15 key => value pairs, the maximum value, well, maybe 100 characters
. I need to add some fields, some to change.
I do it like this:

$c=array();
foreach($a as $b){
           //ну например увеличим цену на 2
          $temp['Price']=$b['Price']*2; 
          //добавим например контрольную сумму
          $temp['crc']=md5($b['name'].$b['Price'].$b['id']);
          
           $c[]=$temp;
}
echo json_encode($c);

All this is spinning on Codeigniter. The server runs on ngnix. When processing such a request, the server returns a 504 error.
I can't figure out what's wrong. It is worth commenting out foreach - everything works fine

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
myfirepukan, 2015-05-08
@myfirepukan

On hosting, what is the limit for the script to work 30 seconds? Probably doesn't make it.
put a microtime on each foreach element and display it on the screen, you will see how much each element is processed - you can draw conclusions.
Although the steps here are so simple... try putting it in a separate script not tied to Codeigniter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question