php - file_put_contents & file_get_contents speed -


i executing 2 functions after each other.

function 1 executes loop 10 times , add values retreives server array. after retrieve txt file file_get_contents , json_decode it. merge file_get_contents array loop array , json_encode , file_put_contents txt file.

function 2 retrieving last line same txt file. using json_decode , array_pop this. return last value of txt file. after remove last line. each time if execute function returns last line , removes it.

i execute them in index.php:

if(is_null(function2($account))){     function1($account, 10);     var_dump(function2($account));  }else{     var_dump(function2($account)); } 

but reason if file empty , function2 (array_pop) should return null. function1 kicks in , generates new pool , adding new lines txt file. if done again execute function2. should show new line right? doesn't. returns null. when repopulated txt file before executing function2. can tell me why is?

thanks.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -