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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Richard QuadlingConnect With a Mentor Senior Software DeveloperCommented:
It is required. preg_match() returns the number of matches. The actual matches are in the $match array.

0
 
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
 
dr_dedoConnect With a Mentor Commented:
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
All Courses

From novice to tech pro — start learning today.