You are here: Re: treat large string like file « PHP Programming Language « IT news, forums, messages
Re: treat large string like file

Posted by petersprc on 11/24/06 02:33

To get the data two chars at a time, you could do:

$len = strlen($data);
for ($i = 0; $i < $len; $i += 2) {
$str = substr($data, $i, 2);
echo "String is \"$str\".\n";
}

To access using a streams interface, you could dump the data into a
temporary file, then read it in. Or create a stream wrapper with
stream_wrapper_register.

Mark wrote:
> So, I've got some PHP code that reads in a file and parses some data as
> it goes along.
> However, now I'm thinking it might be easier for me to store chunks of
> the file in the database rather than all the bits of data, so that it
> can be interpreted in different ways if need be. But the problem is,
> now I can't just use fread to read in two bytes of data, because I've
> already got the whole chunk stored in a variable. And I really don't
> want to deal with tons of substrings, it would be much easier to have a
> sort of file pointer. So is there any way, or any set of functions
> that I can use to deal with this?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация