0017

Manage small data that isn’t as exaggerated as using a database, using PHP and arrays to make it a little easier. method

Manage small data that isn’t as exaggerated as using a database, using PHP and arrays to make it a little easier. method

2013.4.2

When you want to use some data in more than one place, most of the time you’ll use a database to process it, and I think, if the data is not so exaggerated as to use DB, you can create the array data manually and process it with It is sometimes easier to use. A note as I use it sometimes.

Examples of work

Here, we’ll use the common address book as an example.

How to create array data manually

Since we are assuming that the data is small enough not to be exaggerated enough to use a database, the array data in PHP format manually. We will create an associative array in the array, like the following

It may be complicated at first because there are so many parentheses, but by making them in order, starting with the outer parentheses I don’t think the parentheses will be too complicated.

Since it’s manual data that I created myself, I don’t have to worry about security, html formatting, etc. inside. You can include

Turn in foreach.

If you have created the array data in the correct format above, you can use the following foreach method to display it. It can be done.

When the data is updated, you can just modify the original data.