Link to home
Start Free TrialLog in
Avatar of Zado
ZadoFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Display part of string

Hi,

I've got a string like so:
$str = "2008T(12)-1234P(13)-111T(12)-908P(45)-11T(11)";
I need to if chosen part exists, let's say
$part = "1234P";
and display it with number in brackets if exists, so
$final = "1234P(13)" in this case.
otherwise display "echo $part.' does not exists';".

Any ideas?
Thanks for any help.
SOLUTION
Avatar of Amick
Amick
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zado

ASKER

Thanks, but output of you script is "123" instead "1234P(13)"
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zado

ASKER

Excellent, thanks.