Each string behaves as a potential array so calculate string length and traverse the string as an array unless you found desired nth element to separate the string. Log the position of nth element and use "substr" function to extract that particular part of string in some array.
Hope that helps.
Iam new to php would you please show the code to get the result..
Did you try the code in the link? Really shouldn't have to copy it here.
I am writing this no as response to the question that smells like a test , I am writing it because I believe that there is a bad perception for php functions as arguments (I hate PHP that way and luckily PHP hate itself as well) . I will give you a test code that I would like you to run in order to understand ... and test your own what is faster and more sufficient , that might change the way you are thinking.