json encode breaking for large strings



I am trying to json encode an well-formed XML string into a SimpleXMLElement object. But what happens is that, it breaks or exit.


I tried with small xml files and works fine and the issue is with large xml files


Here is the code:



<?php
$directory = "lookup.xml";
$xmlContent = file_get_contents($directory); // get contents of lookup
print_r(simplexml_load_string($xmlContent));
$arrayXml = json_decode(json_encode(simplexml_load_string($xmlContent)),TRUE);
print_r($arrayXml);


lookup.xml files :



1. lookup.xml - 2 MB (works fine)
2. lookup.xml - 13 MB (Not working)


Is it because of a large file or some string breaking??


No comments:

Post a Comment