I needed suggestions for the following scenario.
I have a php variable called $data which holds a lot of information.I am trying to break up the data into fragments using the function explode.
After exploding them into say n fragments, i loop through them and store around 50 lines in array1,50-100 lines in array2 and so on.
$data = explode( "\n" , $data , 388 );
$x = 27;
while( $x < 72 and $x>=27){$arr["x2"] .= $data[$x] . "\n";
$x++;}
$x = 72;
while( $x < 117 and $x>=72){$arr["x3"] .= $data[$x] . "\n";
$x++;}
$x = 117;
while( $x < 162 and $x>=117){$arr["x4"] .= $data[$x] . "\n";
$x++;}
$x = 162;
while( $x < 207 and $x>=162){$arr["x5"] .= $data[$x] . "\n";
$x++;}
$x = 207;
while( $x < 252 and $x>=207){$arr["x6"] .= $data[$x] . "\n";
$x++;}
$x = 252;
while( $x < 297 and $x>=252){$arr["x7"] .= $data[$x] . "\n";
$x++;}
$x = 297;
while( $x < 342 and $x>=297){$arr["x8"] .= $data[$x] . "\n";
$x++;}
$x = 342;
while( $x < 387 and $x>=342){
$arr["x9"] .= $data[$x] . "\n";
$x++;}
$x = 387;
if(!empty($data[$x])){$arr["x10"] .= $data[$x];
$x++;}
If i find that $arr[“x10”] is not empty,then i print sample10.pdf.
If the above is not true ,then i check if $arr[“x9”],if this is true then i print sample9.pdf.Like the following
if(!empty($arr["x10"])){template='https://www.xyz.com/folder/pdf/sample10.pdf';}
if(!empty($arr["x9"])){template='https://www.xyz.com/folder/pdf/sample9.pdf';}
if(!empty($arr["x8"])){template='https://www.xyz.com/folder/pdf/sample8.pdf';}
if(!empty($arr["x7"])){template='https://www.xyz.com/folder/pdf/sample7.pdf';}
if(!empty($arr["x6"])){template='https://www.xyz.com/folder/pdf/sample6.pdf';}
if(!empty($arr["x5"])){template='https://www.xyz.com/folder/pdf/sample5.pdf';}
if(!empty($arr["x4"])){template='https://www.xyz.com/folder/pdf/sample4.pdf';}
if(!empty($arr["x3"])){template='https://www.xyz.com/folder/pdf/sample3.pdf';}
if(!empty($arr["x2"])){template='https://www.xyz.com/folder/pdf/sample2.pdf';}
if(empty($arr["x2"])){template='https://www.xyz.com/folder/pdf/sample.pdf';}
I tried to execute this code,but the code just hangs and it gives me an error.I am trying to write a switch case but am not sure of how to proceed with that.
Any help with the code would be appreciated.
Thanks in advance.
First off, why don’t you try something like this:
… but I’m not sure what you’re trying to do with the “template=” line. It’s not valid PHP, so I don’t know what it’s supposed to do.