将数据从数据库中提取到php数组中

I've created an array of categories in php like this:

$cats=array("Coffee", "Beverages", "Drinks", "Snacks/Desserts");

But I want to make it like dynamic. Let's say when I update my database via my website (delete-change name-add a new category), I need this array to follow those updates.

Is is possible? Or else, how can I deal with it?

You can indeed, just use array_push() !

http://php.net/manual/en/function.array-push.php

It pushes your passed variables to the end of the Array, and it increases its size.

No. Array can not follow your updates. But you can create the array based on database content. Which is usually what all sites do.