-1

I get data from exchanges, but they have a rate limit, means I cannot fetch the data too often. However, during programming I would like to start at the point where I had already the data. The last line of the fetched code is just a var_dump. How can I store that and start from that point again and again, without fetching new data?

Ronald Wiplinger
  • 2,033
  • 3
  • 14
  • 20
  • The thing you are `var_dump`ing is a variable, no? If so can't you just use it like that.. – user3783243 Jun 25 '18 at 03:35
  • create new session and save the data in that session, then you can unset it later when you don't need the data anymore. – bdalina Jun 25 '18 at 03:54

2 Answers2

1

Encode it as JSON using json_encode and store it in a file or database to manipulate later without having to make a new call to the exchange.

jstur
  • 659
  • 6
  • 12
0

var_dump is not meant for saving a variable nor for saving state. This function displays structured information about one or more expressions that includes its type and value. php.net

If you need the data to be persistent, Meaning, you will need it for a few weeks,months, year or infinity, you have to encode it in JSON and store it somewhere like @jstur said. However, if you are using a relational database like MySQL/MariaDB, you can create another table and store it without encoding.

If you will need the data while the user is currently logged-in. Saving it to the session is a way to go.But please be aware with php session's limitation and do not overuse it as it may affect your application's performance.

ken
  • 51
  • 1
  • 4