How can I read a blob field that has been pulled from the database and has formatted text?
I need to be able to read line by line in order to populate a table, basically get the contents from each line. thanks
Read a blob field line by line
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13592
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Read a blob field line by line
Probably the easiest is to split the text on newlines into an array. The simplest would be:
If line endings can be mixed then more complicated:
Then just
Code: Select all
$lines = explode("\n", $text); // or \r
Code: Select all
$lines = preg_split("/((\r?\n)|(\r\n?))/", $text);
Code: Select all
foreach($lines as $line) {
(#10850)