It appears to me you wish to display some $\LaTeX$ on your web page. You don't need to use PHP to do this, you can simply put the code(s) wrapped in the dollar tags as text within the appropriate HTML elements.
Thank you for your reply.
I want to create some multiple choice questions. The questions are kept in an array. Suppose the array contains 100 questions. Some of the questions contains Latex equations. I want to display only 10 questions randomly. In that situation, it is essential to use php.
So please help in this regard.
Then, use a while loop to randomly choose questions from the array (keeping track of questions already selected so they are only selected once). As the questions are chosen, wrap them in whatever HTML you want along with $\LaTeX$ tags, and concatenate them into a single string. Then echo this string to the page in the appropriate place.