RE: [PHP] Pulling data out of a string
| From: | James E Hicks III | Date: | Fri, 02 May 2003 20:54:36 +0000 |
| Subject: | RE: [PHP] Pulling data out of a string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146199@lists.php.net to get a copy of this message | ||
Do a str_replace on all your variable names to a common delimeter, then explode
this variable on that delimeter, and if all the fields are always present you
won't have a problem with this.
$text = str_replace("Name:","*",$text);
$text = str_replace("Type:","*",$text);
$text = str_replace("File Number:","*",$text);
...;
$var = explode("*",$text);
for ($x=0; $x<(count($var)/$numfields); $x+$numfields){
$name = $var[(x)];
$type = $var[(x+2)];
$filenum = var[(x+3)];
....;
}
James
-----Original Message-----
From: Richard Kurth [mailto:rdkurth@starband.net]
Sent: Friday, May 02, 2003 4:36 PM
To: php-general@lists.php.net
Subject: [PHP] Pulling data out of a string
I need a way to pull the data out of this string. So that My Company
is in a variable called Name and Corporation is in Type and C17481-2001
is in File Number and NEVADA is in the variable State ....etc
Could somebody point me in the right direction to do this. How would i
separate this data?
$text="Name: My Company Type: Corporation File Number: C17481-2001State: NEVADA
Incorporated On: July 02, 2001Status: Current list of officers on fileCorp Type:
Non-profitResident Agent: AMERICAN LEGAL SERVICES (Accepted)Address: 237 S.
SIERRA STREET RENO NV89501- President:ROBERT DOBYNS Address: 16843 FM 1314
CONROE TX77302- Secretary:RICK PENNY Address: 23026 RED LEO SPRING TX77389-
Treasurer:DEBORAH PENNY Address: 23026 RED LEO SPRING TX77389- ";
--
Best regards,
Richard mailto:rdkurth@starband.net
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php