In yesterday Interview I was asked that how to reverse a string with out using any string function like strrev() or strlen(). I found this example on website but it gives error.is it possible to do this without strlen().
Uninitialized string offset: -1 in D:\xampp\htdocs\PhpProject1\index.php on line xx
$string = "ZEESHAN";
$i =0;
while(($string[$i])!=null){
        $i++;
}
$i--;
while(($string[$i])!=null){
        echo $string[$i];
$i--;
}
                $string = 'zeeshan';
$reverse = '';
$i = 0;
while(!empty($string[$i])){ 
      $reverse = $string[$i].$reverse; 
      $i++;
}
echo $reverse;
                        Try -
$string = "ZEESHAN";
$j = 0;
while(!empty($string[$j])) {
   $j++;
}
for($i = ($j-1); $i >= 0; $i--) {
    echo $string[$i];
}
Output
NAHSEEZ
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With