PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
AiRSh33p
Forum Newbie
Posts: 2 Joined: Thu Jul 26, 2007 6:40 pm
Post
by AiRSh33p » Thu Jul 26, 2007 6:52 pm
Hello,
I have a problem with my PHP script, basically I want the PHP script to search itself to find a certain word (including wildcards)
For example
if the text was:
Code: Select all
something123 has this112 user=happy etc345 jeff...
and I wanted the PHP script to search the value in the text in this case happy then if it exists copy user=happy and save it as:
Code: Select all
$userexample = "FOUND TEXT"
print $userexample
Thanks Nic
Last edited by
AiRSh33p on Fri Jul 27, 2007 2:26 pm, edited 1 time in total.
stereofrog
Forum Contributor
Posts: 386 Joined: Mon Dec 04, 2006 6:10 am
Post
by stereofrog » Fri Jul 27, 2007 3:27 am
Try regular expressions
Code: Select all
$a = "something123 has this112 user=happy etc345 jeff... ";
preg_match('/user=(\S+)/', $a, $m);
print $m[1]; // prints 'happy'