Things to do in Cape Town, the Helderberg, and the Cape Winelands

Tag array key

PHP: Identify the Offset of a Specific Array Element

To learn the offset or array key for a specific array element in a given array turns out to be fairly easy, thanks to the extra search parameter that the always useful array_keys (return all the keys or a subset… Continue Reading →

PHP: Compare the Keys of an Array and find the Difference

To compare two arrays to see if there is a difference, one often makes use of the array_diff function which takes two arrays, compares array1 against array2 and then returns the difference. Now if you actually want to check for… Continue Reading →

PHP: How to Get the Associated Key from an Array given a Value

If you have a value and you suspect that it might be contained within your array, can you somehow find the key linked to that value if it does exist? The answer is yes, thanks to the handy array_search function… Continue Reading →

© 2021 An Exploring South African — Powered by WordPress