Splitting a string into characters is relatively simple: $char_array = str_split($string).
Howevre, I have a feeling this might be an X-Y question, so please take a step back and describe the actual problem you're trying to solve instead of what you perceive as the solution. What do you need this function for?