[SOLVED] Text Manipulation

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

Post Reply
AiRSh33p
Forum Newbie
Posts: 2
Joined: Thu Jul 26, 2007 6:40 pm

[SOLVED] Text Manipulation

Post 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
Last edited by AiRSh33p on Fri Jul 27, 2007 2:26 pm, edited 1 time in total.
User avatar
webgroundz
Forum Commoner
Posts: 58
Joined: Thu Jun 21, 2007 1:20 am
Location: Philippines

Post by webgroundz »

try to use :

Code: Select all

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

:) :) :)
User avatar
stereofrog
Forum Contributor
Posts: 386
Joined: Mon Dec 04, 2006 6:10 am

Post 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'
Post Reply