Quesion to string parsing
Posted: Thu Jul 22, 2004 8:21 am
Hello,
String I:
---------
$output=
Name: 1
Company Name: 2
Street: 3
City: 4
Code: 5
Country: 6
Tel: 7
String II:
----------
$output=
Name: 1
Street: 2
City: 3
Code: 4
Country: 5
Fax: 6
=> I want to pick out the data from the strings. Since the information varies, I want an array like this (e.g. for String II):
array["Name"] = 1
array["Street"] = 2
array["City"]=3
...
$array = explode("\n",trim($output)); splits a string by string an returns an array of strings.
So I have e.
array[0]=Name: 1
array[1]=Street: 2
array[2]=City: 3
==>Question, how do I pick out each element of the array and make an associative array out of it?
Thanks,
visionmaster
String I:
---------
$output=
Name: 1
Company Name: 2
Street: 3
City: 4
Code: 5
Country: 6
Tel: 7
String II:
----------
$output=
Name: 1
Street: 2
City: 3
Code: 4
Country: 5
Fax: 6
=> I want to pick out the data from the strings. Since the information varies, I want an array like this (e.g. for String II):
array["Name"] = 1
array["Street"] = 2
array["City"]=3
...
$array = explode("\n",trim($output)); splits a string by string an returns an array of strings.
So I have e.
array[0]=Name: 1
array[1]=Street: 2
array[2]=City: 3
==>Question, how do I pick out each element of the array and make an associative array out of it?
Thanks,
visionmaster