Issue of memory exceed when update array values in loop in php -


the situation have array of 15000 records , each record have 67 key-value paired values. want update values using trim, str_replace or type-cast, error of php memory leak. don't understand why happening. array format this

array (     [0] => array         (             [id] => 1             [parent_id] => 1             [login] => 123             [login_nickname] =>              [password] => 123             [subuser] => 0             [subuser_id] =>              [email] => usersemail@email.com         ),        [1] => array         (             [id] => 1             [parent_id] => 1             [login] => 123             [login_nickname] =>              [password] => 123             [subuser] => 0             [subuser_id] =>              [email] => anotheruser@email.com         ) ) 

in array have fields comments, address , want them trim, str_replace, fields branches(array) want type-cast in object. when error of memory exceed this

fatel error: allowed memory size of 134217728 bytes exhausted(tried allocate 49 bytes) in var/www/html/myproject/application/models/member.php on line 28

fyi: when echo these values in loop using these functions(trim,str_replace,type-cast etc.) loop working fine , printing value successfully.

i don't understand problem , please me.

my foreach loop this

foreach($member_list $index=>$member){    foreach($member $key=>$value){       $member_list[$index][$key] = str_replace(array("\n", "\t", "\r"), " ", trim($value));    } } 

this error occur in loop.

this problem related php script consuming lot of memory. in case, amount of data large, 504 gateway timeout issue start coming pretty frequently. should either use batch-processing(background processing) technique or execute script using cli or curl. these 2 techniques proven methodologies in world of php handle large running jobs.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -