Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need Help With This Code

    PHP Code:
    function functionrenamed$str ){ 

       
    $str explode' '$str ); 
        
       
    $num count$str ); 
        
       
    $codeon false
        
       for( 
    $i 0$i $num$i++ ){ 
        
          if( 
    $codeon == false ){ 
           
             if( 
    ereg"\["$str[$i] ) ){ 
                 
                
    $str_cur explode'['$str[$i] ); 
                 
                

                # 
                 
                
    if( ereg"]"$str_cur[1] ) ){ 
                    
                   

                    
                   
    $str_cur_1 explode']'$str_cur[1] ); 
                    
                   

                   # 
                    
                   
    $code $str_cur_1[0]; 
                    
                   switch( 
    $code ){ 
                      default: 
                         
    $code_op "[$code]"
                      break; 
                      case 
    'b'
                         
    $code_op '<b>'
                      break; 
                      case 
    'i'
                         
    $code_op '<i>'
                      break; 
                      case 
    'img'
                         
    $code_op '<img src="'
                      break; 
                   } 
                    
                   
    $codeon true
                    
                   
    $str[$i] = $str_cur[0] . $code_op $str_cur_1[1]; 
                    
                } 
              
             } 
           
          } 
          elseif( 
    $codeon == true ){ 
           
             if( 
    ereg"\[/"$str[$i] ) ){ 
                 
                
    $str_cur explode'[/'$str[$i] ); 
                 
                

                # 
                 
                
    if( ereg"]"$str_cur[1] ) ){ 
                    
                   

                    
                   
    $str_cur_1 explode']'$str_cur[1] ); 
                    
                   

                   # 
                    
                   
    $code $str_cur_1[0]; 
                    
                   switch( 
    $code ){ 
                      default: 
                         
    $code_cl "[/$code]"
                      break; 
                      case 
    'b'
                         
    $code_cl '</b>'
                      break; 
                      case 
    'i'
                         
    $code_cl '</i>'
                      break; 
                      case 
    'img'
                         
    $code_cl '">'
                      break; 
                   } 
                    
                   
    $codeon false
                    
                   
    $str[$i] = $str_cur[0] . $code_cl $str_cur_1[1]; 
                    
                } 
              
             } 
           
          } 
           
          
    $str_c .= "$str[$i] "
        
       } 
        
       return 
    $str_c;    




    Can anyone tell me what this code does?
    Last edited by liorean; 05-11-2004 at 01:13 AM. Reason: I guess this is PHP. Over to you...

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Few things:
    1. this isn't Javascript, it looks like Perl or PHP -- so wrong forum (DOM??)
    2. this looks like homework: professor gives you some code, asks you what it does and to give the function a meaningful name. I don't think we're supposed to do people's homework here: (http://www.codingforums.com/showthread.php?t=2090)
    3. what's the input? it's not impossible to figure out what this function does without the input, but it'd be a lot easier if we knew.
    4. wrap your code in [ code ] [ /code ] tags (no spaces) and format it so it's readable -- you'll get a better response


    Good luck,
    Sadiq.

  • #3
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it looks like it replaces bbcode tags with html tags


  •  

    Posting Permissions

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