Sorunlar birden kullanıyorsanız php ifadeleri

0 Cevap

Ben aşağıdaki senaryoda için önerileri gerekli.

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++;}

Ben bu $ dizi ["x10"] boş değil bulursanız, o zaman ben sample10.pdf yazdırın.

Yukarıdaki doğru değilse bu doğruysa $ dizi ["x9"], o zaman ben şu sample9.pdf.Like yazdırırsanız, sonra ben kontrol

 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.

0 Cevap