Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get part of string 1

Status
Not open for further replies.

brownfox

Programmer
Jan 5, 2003
173
0
0
GB
Here is my string:
Code:
(user_id LIKE '%2568%')
And I want to get 2568 from that string. Does anyone know how I could do this?
T.I.A
 
use strpos() to find out if 2568 occurs in your string. It'll return the position of the first character. It will return false if 2568 isnt there.

Code:
$result = strpos($yourString, '2568');

preg_match() and strstr() are your alternate choices.

Good luck!
 
But 2568 is a variable in this case so:
$parts = split( "%", $string );
echo $parts[1];
is the perfect answer :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top