First, you pass a variable into Get_array() called $subcat that doesn't appear to be used?
Then, you select one field (sub_cat) that you later explode() into your $cats array. I will take your word for it that the sub_cat field contains a comma seperated list of values. I also note that you concatenate "<br>" onto the $temp string prior to the explode(); so I assume that you want this to end up concatenated to the last element of your array? It also looks like you only expect to get one row back from your querry, otherwise $cats will end up only having the values from the last row returned.
I am making these observation only so that you can refute or clarify my clumsy assumptions as to what this script is supposed to be doing; please bear with me...
You then add "test" as the last value to your array (presumably for exactly that reason) and set $ar_len to the size of $cat_array which has not been previously initialized or populated anywhere in the function. This doesn't matter because you don't use it anywhere else...
You then use the list() and each() functions in a while loop to output the contents of the $cats array. If $cats has values in it, the only possible output for this loop will be a list of numbers from 0 to the number of elements in the array. This is because the each() function returns an array of key/value pairs, not the individual values of your array. change "list($value)" to "list($key, $value)" to get the array values into $value. If nothing is printing at this point, you do not have a properly populated array. In any case, you should at least get the "test" to print...
The second function is fine, except for the fact that the closing "}" is missing for the function. If your first function is populating $cats correctly, then this function should print the list of values.
Let me know if my assumptions were correct and exactly what output you are getting from the script and we'll take it from there.
-- Rich Rijnders
-- Irvine, CA US