I have a text file: 'bookdata' with the following structure:
abcd@yahoo.com:1:20.30
efgh@hotmail.com:4:5.05
...
email : total no. of books : total books read.
My problem is to separate each part of the various strings using an associative array as follows:
+-----------------------------------------------+
| yahoo.com |
+---------------+------------------+------------+
| abcd@yahoo.com | 1 | 20.30 |
| efgh@yahoo.com | 4 | 5.05 |
+---------------+------------------+------------+
My approach so far is as follows:
I have a function makeArray() that has the data from the read txt file:
public function makeArray()
{
$readTxtData = $this->read('bookdata');
//Get the domain from data....
$domain = preg_split("~[A-Za-z](.*?)@~", $readTxtData);
return $domain;
}
The result:
Array
(
[0] =>
[1] => yahoo.com:7:8.35
[2] => hotmail.com:4:5.59
)
The array should look like this:
Array
(
[yahoo.com]
(
[0]
(
[0] => abcd@yahoo.com
[1] => 7
[2] => 8.35
)
[1] => Array
(
[0] => efgh@yahoo.com
[1] => 1
[2] => 8.36
)
[2] => Array
(
[0] => oyp@yahoo.com
[1] => 9
[2] => 13.42
)
).....
Thanks.