Ali Demirci
Ali Demirci

Reputation: 5442

why does this for loop returns null?

<?  
for ($i=0; $i<=9; $i++) {


    $b=urlencode($cl[1][$i]);
    $ara = array("http://anonymouse.org/cgi-bin/anon-www.cgi/", "http%3A%2F%2Fanonymouse.org%2Fcgi-bin%2Fanon-www.cgi%2F");
    $degis   = array("", "");
    $t = str_replace($ara, $degis, $b);
    $c="$t";
    $base64=base64_encode($t);


    $y=urldecode($t);
    $u=base64_encode($y);
    $qwe = "http://anonymouse.org/cgi-bin/anon-www.cgi/$y";
    $ewq = "h.php?y=$u";
    $bul = ($qwe);
    $degistir = ($ewq);
    $a =str_replace($bul, $degistir, $ic);
}
?>

when i put $cl[1][0], $cl[1][1], $cl[1][2] works successfull but when i put $i its returning null. why is this happening?

**I'm trying to change EACH url to base64 codes that I received from remote url with preg_match_all **

Upvotes: 1

Views: 115

Answers (1)

pakore
pakore

Reputation: 11497

Have you checked that $c1[1] has 10 elements? (From $c1[1][0] to $c1[1][9] there are 10 elements, not 9.

Maybe you are getting null for the last one $c1[1][9]. Try to do a var_dump($c1[1]) to check that it contains all the elements that you expect.

Update:

Change the this line

for ($i=0; $i<=9; $i++) {

into this

for ($i=0; $i<9; $i++) {

Upvotes: 2

Related Questions