Today I was working on some code that had arrays structured like this:
$foo = [
'a' => [ 1, 2, 3, 4 ],
'b' => [ 5, 6, 7 ],
I needed to calculate the total number of items in the nested arrays. I didn’t find a PHP function to help me with that but I came up with this idea:
Sometimes a WordPress plugin you are writing extends the functionality of another plugin or simply relies on it to work. In these cases, you need to make sure your plugin’s dependencies are installed and active to be sure you can use their functions.
There are some existing libraries that you can use to make sure that a plugin is running – one such library is TGM Plugin Activation. Checking if another plugin is running, however, is fairly simple and you can implement it yourself if you don’t want to pull an external library for the purpose.