|
|
|
||||
|
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() |
|
|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
|
Thread Tools |
|
|
#1 |
|
Confirmed User
Industry Role:
Join Date: Jun 2003
Location: Los Angeles, CA
Posts: 512
|
Anyone know why the following does not return desired results and how to get it to?
Code:
$string = 'a,b,c,d';
if(eregi("(a)|(adf)|(c)",$string,$matchedtext)){
echo $matchedtext[1]; // This returns an "a" which I want
echo $matchedtext[2]; // This is empty, I want it to return a "c"
}
|
|
|
|
|
|
#2 |
|
Confirmed User
Industry Role:
Join Date: Jun 2003
Location: Los Angeles, CA
Posts: 512
|
Code should have read:
Code:
$string = 'a,b,c,d';
if(eregi("(a)|(c)|(adf)",$string,$matchedtext)){
echo $matchedtext[1]; // This returns an "a" which I want
echo $matchedtext[2]; // This is empty, I want it to return a "c"
}
|
|
|
|
|
|
#3 |
|
Confirmed User
Join Date: Oct 2003
Location: Command Central, West Palm Beach, Fl
Posts: 1,794
|
who don't you do a print_r($matchedtext) to see what's in there?
__________________
I do stuff - aIm CS_Jay_D |
|
|
|
|
|
#4 |
|
Confirmed User
Join Date: Aug 2005
Location: Las Vegas, NV
Posts: 1,099
|
not sure exactly what you are trying to do here, but take some time to read up on regular expressions in PHP and you should be able to figure it out.
http://www.regular-expressions.info/php.html http://www.php.net/manual/en/function.ereg.php
__________________
Spunky Dollars | Need Content? Paysite Owners: Protect Your Members Area with Strongbox 361-574-229 |
|
|
|
|
|
#5 |
|
Confirmed User
Industry Role:
Join Date: Jun 2003
Location: Los Angeles, CA
Posts: 512
|
print_r($matchedtext) returns:
Array ( [0] => a [1] => a [2] => [3] => ) My understanding is matchedtext[0] is supposed to return the complete string matched, matchedtext[1] is supposed to return the substring which starts at the first left parenthesis, matchedtext[2] the next and so on. For some reason matchedtext[2] is not returning the letter "c" as I would expect. |
|
|
|
|
|
#6 | |
|
Confirmed User
Industry Role:
Join Date: Jun 2003
Location: Los Angeles, CA
Posts: 512
|
Quote:
|
|
|
|
|
|
|
#7 |
|
Confirmed User
Join Date: May 2004
Location: SW Palm Bay, Florida
Posts: 1,323
|
You owe me a blow job.
It could be shorter, but that takes time, more thought and money. PHP Code:
__________________
subarus. |
|
|
|
|
|
#8 |
|
Confirmed User
Industry Role:
Join Date: Jun 2003
Location: Los Angeles, CA
Posts: 512
|
thank you!
|
|
|
|