/    Sign up×
Community /Pin to ProfileBookmark

PHP search string for a word

I have a <textarea> that has:

other stuff
[COLOR=Red]Size: Size Choice
Color:: Color Choice[/COLOR]

other stuff

I want the PHP to search until it finds “Size:”, then take the text after that until it reaches the end of the row (n).

Is there a function that does that? I looked at the manual, but I’m not using the right keywords.
Thanks

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYNov 24.2005 — Why don't you do as other people and have different input fields?
<i>
</i>&lt;input type="text" name="username" id="username"&gt;

[url=http://www.w3.org/TR/html4/interact/forms.html#h-17.4]more about the INPUT tag[/url], you also might wanna check what other type of forms there are (on the page)

i believe you'd wanna use a select tag (drop-down) for the size and color choices
Copy linkTweet thisAlerts:
@LocalHeroauthorNov 24.2005 — It's far more complicated than that. I understand html and php fine, I just want to know if it's possible to search a string for a keyword and get the text after. I just need to know what it's called so I can search myself.
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYNov 24.2005 — regular expressions
Copy linkTweet thisAlerts:
@bokehNov 24.2005 — [code=php]<?php
$target_string = '
other stuff
Size: big
Color: red
other stuff
';

// size
preg_match('#Size:(.+)#i', $target_string, $matches);
$size = trim($matches['1']);
echo $size;

echo '<br>';

// colour
preg_match('#Color:(.+)#i', $target_string, $matches);
$color = trim($matches['1']);
echo $color;
?>[/code]
Copy linkTweet thisAlerts:
@LocalHeroauthorNov 24.2005 — Brilliant! Thanks a bunch!
×

Success!

Help @LocalHero spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...