I believe someone gave the regex code for it already, but if you wanted to do 
it the clumsy way (for those of us who are regex challenged still) here's an 
alternative:

$str = "cn=emailadmin,ou=services,dc=domain,dc=net";

$argsarray = explode(",", $str);

foreach ($argsarray as $argstr) {
  list($arg, $val) = explode("=", $argstr);
  $newarr[$arg] = $val;
}

echo $newarr['cn'];



Then you have access to all the parameters being given.


I'm pretty sure there's a more elegant way to do this even the clumsy way I did 
it, but just giving a basic example of how else you might be able to get that 
information.

-TG


= = = Original message = = =

Hey folks

I don't want to "just get you to do the work", but I have so far tried
in vain to achieve something...

I have a string similar to the following;

cn=emailadmin,ou=services,dc=domain,dc=net

I want to extract whatever falls between the 'cn=' and the following
comma - in this case 'emailadmin'.

Question(s);
is this possible via a regular expression?
does php have a better way of doing this?

Some pointers would be greatly appreciated. Once I have working, I will
be creating a function which will cater for this and will post to this
list if anyone is interested?

Cheers
Steve

-- 
Steve Turnbull


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to