Results 1 to 9 of 9

Thread: [RESOLVED] PHP While....Loop - Help Needed

Threaded View

  1. #1

    Thread Starter
    Fanatic Member modpluz's Avatar
    Join Date
    Sep 2005
    Location
    Lag, NG
    Posts
    633

    Resolved [RESOLVED] PHP While....Loop - Help Needed

    hi guyz, i have this question like;

    In ASP there is something like
    Code:
    Do While arg
    
    some more codes...
    
    Loop
    what that does in ASP/VB is that it loops until the argument is false

    and i thought it should be doing the same thing with PHP's while function

    but it doesn't instead it loops forever.

    take this code for example;

    Code:
    'Note that this is an ASP Code
    strPost = "[EDIT]C:\Program Files\bpmp\htdocs\smat_3.jpg[/EDIT]"
    Do While InStr(1, strPost, "[EDITED]", 1) > 0 AND InStr(1, strPost, "[/EDITED]", 1) > 0
    
    'some more codes...
    
    Loop
    but if i try that in PHP using the While....Loop then it loops for ever

    pls note the function InStr() function,this is used to check if a given string occurs in another string and also it returns the position where the occurence starts and i have a similar php function that does that.
    here it is.

    PHP Code:
    function InStr($string,$find,$CaseSensitive false) {
            
    $i=0;
            while (
    strlen($string)>=$i) {
                unset(
    $substring);
                if (
    $CaseSensitive) {
                    
    $find=strtolower($find);
                    
    $string=strtolower($string);
                }
                
    $substring=substr($string,$i,strlen($find));
                if (
    $substring==$find) return $i;
                
    $i++;
            }
            return -
    1;
        } 
    Last edited by modpluz; May 3rd, 2006 at 09:42 PM.
    If you want the rabbit to hop, move the carrot - Paul Kellerman(Prison Break)

    onError GoTo http://vbforums.com



    My Bits:
    VB6: Change Column Name in MS ACCESS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width