Page 1 of 1

[SOLVED] Text Manipulation

Posted: Thu Jul 26, 2007 6:52 pm
by AiRSh33p
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

Posted: Thu Jul 26, 2007 6:58 pm
by webgroundz
try to use :

Code: Select all

strstr()
see the manual
http://www.php.net/strstr

:) :) :)

Posted: Fri Jul 27, 2007 3:27 am
by stereofrog
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'