1

am using the PocketMine API (not for web), and i have ran a function that returns an array, storing multiple pocketmine\item\Item arrays.

This could be thought as an array storing objects.

Basically, what I need to do is store this array, but not in the form as it is. (An array containing objects.) I tried serialize() and json_encode(). Neither of these work in my situation.

Is there any way i can do this? Thanks.

SOFe
  • 7,867
  • 4
  • 33
  • 61
Samueljh1
  • 129
  • 1
  • 11

1 Answers1

0

So how do you want your data stored? Is thr object always the same? The object always has the same attributes? If so were do you want to store it? If you want to store in a mysql DB AND the objects always have the same attributes you can foreach every object in the array and insert into the DB.

For example if you have an array of users and the object user is like this: Name, username, password, email

You foreach your array and then insert:

Foreach($users as $user){
  Sql command:  Insert into users (name, username, password, email) values ($user->name, $user->username, $user->password, $user->email)
  }

Is that want you pretend?

Pedro Silva
  • 263
  • 2
  • 17