These days I seem to looking a lot a print_r output. For the uninitiated, print_r is a handy PHP function to allow you to print the contents of an array in a neat, readable format. Continue reading “Parse Print_r output and convert into CSV”
Tag: array
Find duplicates in an array with PHP
Here is a function to find duplicate items in an array.
/** * Takes an array and returns an array of duplicate items */ function get_duplicates( $array ) { return array_unique( array_diff_assoc( $array, array_unique( $array ) ) ); }
Convert CSV data into an associative array
If you want to convert comma separated values into an associated array, then use the following code.
Continue reading “Convert CSV data into an associative array”