PHP equivalent of Classic ASP array member reference

In Classic ASP this code would print "s" to the browser window:
<%
Set regEx = New RegExp
regEx.Pattern = "s"
Response.Write regEx.Execute("test")(0)
%>

What would be the PHP equivalent (if any) of the array reference above?

Note my goal with this example is to understand if it is possible directly address a member of a resulting array in one step, or if it is required to use more than one step such as:

<?php
preg_match('/s/','test',$match);
echo $match[0];
?>
LVL 27
ddrudikAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LordWolfyCommented:
A similar question seems to have been previous asked on thsi site:

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_22910308.html
0
Richard QuadlingSenior Software DeveloperCommented:
It is required. preg_match() returns the number of matches. The actual matches are in the $match array.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dr_dedoCommented:
see, preg_match doesn't return an array as most functions would do, it assigns array value to the passed parameter, that's why you can't access it as in asp. you have to do that on two steps
0
ddrudikAuthor Commented:
I was hoping the answer was different, but thanks for the quick help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.