Loading ...
Sorry, an error occurred while loading the content.

Re: [bang-phpug] PHP While Loop Question, please answer

Expand Messages
  • janakiraman
    Hi thisistrinath, Otherwise use like this and check it out..
    Message 1 of 7 , Dec 29, 2008
    • 0 Attachment
      Hi thisistrinath,
      Otherwise use like this and check it out..
      <?php

      $a="<html><head></head><body><a href=";//a string
      $l=strlen($a) ;
      $i=0;
      while($i<$l){
      if($a[$i] =="<" && $a[$i+1]=="a" && $i<$l)
      break;
      $i++;
      }
      echo $i;
      ?>

      Thanks

      B. Janakiraman

      --- On Mon, 29/12/08, Udayakumar Sarangapani <udayakumar.sarangapani@...> wrote:
      From: Udayakumar Sarangapani <udayakumar.sarangapani@...>
      Subject: Re: [bang-phpug] PHP While Loop Question, please answer
      To: bang-phpug@yahoogroups.com
      Date: Monday, 29 December, 2008, 1:03 PM











      Hi Srikanth,



      When i debugged and ran your code, i got 0 as the output. I don't know the

      reason.



      why don't you change the logic as follows?



      <?php

      $a="<html><head> </head><body> <a href=";//a string

      $l=strlen($a) ;

      $j = -1;



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

      if ($a[$i] == "<" && $a[$i+1] == "a") {

      $j = $i;

      }

      }



      if ($j != -1) {

      echo $j;

      }

      ?>



      On Sun, Dec 28, 2008 at 12:08 PM, thisistrinath

      <thisistrinath@ yahoo.co. in>wrote:



      > Hello,

      > It seems odd to ask a question on while loop but the problem

      > itself is equally odd.

      > $a="<html><head> </head><body> <a href=";//a string

      > $l=strlen($a) ;

      > $i=0;

      > while($a[$i] !="<" && $a[$i+1]!="a" && $i<$l){$i++; }

      > echo $i;

      > A simple thing as this should give me the output 25, whereas it is

      > giving me 9. Please tell me where is the problem or is that the PHP

      > while loop cannot check more than two conditions at a time(as here are 3)..

      > Thank you

      > -Trinadh

      >

      >

      >



      [Non-text portions of this message have been removed]



























      Connect with friends all over the world. Get Yahoo! India Messenger at http://in.messenger.yahoo.com/?wm=n/

      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.