Tag Archives: array

PHP: Return all String Permutations for a 1 Dimensional Array

Getting all the possible string permutations of an array can be pretty useful if you are trying to unlock something and this nifty little function does exactly that: Continue reading

Posted in PHP | Tagged , permutation, , string permutation | View Comments

PHP: Merge Two Arrays but Keep Their Keys Intact

Combining two or more arrays whilst keeping their keys intact in PHP is deceptively simple – though not if you assume you need to use a function like array_merge to achieve this! As you scroll through the various array functions … Continue reading

Posted in Tutorials | Tagged , , , , | View Comments

PHP: Implode a Multi-dimensional Array

PHP’s implode is a pretty handy function to flatten any array into a single string value, using any piece of ‘glue’ (basically a substring) that you specifiy to put everything together. Of course, extending this function to handle multi-dimensional arrays (or matrices if you prefer) is a pretty simple matter of quickly whipping up a recursive version.
Continue reading

Posted in Technology & Code, Tutorials | Tagged , , , , , , , , | View Comments

PHP: Re-index an Array

Simply make use of the handy PHP array_values function which basically takes an input array, retrieves all values from it and then creates a new array with all those values tucked behind a nice sequential numeric index. Continue reading

Posted in Technology & Code, Tutorials | Tagged , , , , , | View Comments

PHP: Delete all Values to Reuse a Keyed Array

It’s sometimes pretty valuable to reuse array structures if you’re kind of doing a task over and over again, and don’t necessarily want to recreate the array’s keyed structure from scratch with each iteration. Continue reading

Posted in Technology & Code, Tutorials | Tagged , , , , , | View Comments
Navigation »