Is there an existing function which can be implemented the same way as fread but for a string?
for example.
while($string = str_read($huge_string, 500)) {
echo strlen($string); // 500
}
My current code looks like this.
$length = 8192;
$array = str_split($xml, $length);
while($string = array_shift($array)){
if (! xml_parse($parser, $string, false))
{
return xml_error_string(xml_get_error_code($parser));
}
}
xml_parse($parser, '', true);
xml_parser_free($parser);
Is this the most efficient way of doing this or can it be improved to offer better performance ?
would using a $length of int_get('memory_limit'); be better as it will use less iterations ?