how to store arrays into a database

What WP does for arrays (and objects) on some contexts (such as post fields) is using maybe_serialize()/maybe_unserialize() to turn such types (and just them) to and from serialized (string-typed) representation.

While this simplifies workflow it comes with penalties, such as being unable to properly query through such data and common issues with migration (seriazlization-unaware tools or actions easily ruin serialized strings).

If you have control over design of custom table and it serves specific dedicated function — you should probably design it in a way that you don’t store whole arrays in first place.