PHP Developers Network
http://forums.devnetwork.net/

Read a blob field line by line
http://forums.devnetwork.net/viewtopic.php?f=1&t=142168
Page 1 of 1

Author:  paulin1 [ Tue Jan 12, 2016 11:04 pm ]
Post subject:  Read a blob field line by line

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

Author:  Christopher [ Wed Jan 13, 2016 12:36 pm ]
Post subject:  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:
Syntax: [ Download ] [ Hide ]
$lines = explode("\n", $text);     // or \r

If line endings can be mixed then more complicated:
Syntax: [ Download ] [ Hide ]
$lines = preg_split("/((\r?\n)|(\r\n?))/", $text);

Then just
Syntax: [ Download ] [ Hide ]
 foreach($lines as $line) {

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/