Web Analytics Made Easy -
StatCounter why this dont work ? php bug ? - CodingForum

Announcement

Collapse
No announcement yet.

why this dont work ? php bug ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • why this dont work ? php bug ?

    PHP Code:
    print_r($res[0]) = 

    Array
    (
        [
    desde] => 150
        
    [preco_negociar] => 1
        
    [vendido] => 2
        
    [cilindrada] => campos[cilindrada]
        [
    registos] => campos[registos]
        [
    kms] => campos[km]
        [
    cv] => 150
        
    [cor] => campos[cor]
        [
    ano] => 2002
        
    [img_0] => ccb_003_1159366126.jpg
        
    [img_1] => ccb_05_3686_1159366126.jpg
        
    [img_2] => ccb_003_1159369021.jpg
        
    [img_3] => ccb_05_3686_1159369021.jpg
        
    [modelo] => 5
        
    [versao] => campos[versao]
        [
    categoria] => 2
        
    [carrocaria] => 6
        
    [portas] => 3
        
    [combustivel] => 2
        
    [caixa] => 2
        
    [traccao] => 1
        
    [estado] => 2
        
    [garantia] => 6
        
    [activo] => 1
        
    [pai] => 17
        
    [dtini_promo] => 2006-05-01
        
    [dtfim_promo] => 2006-05-31
        
    [dtini_destaque] => 0000-00-00
        
    [dtfim_destaque] => 0000-00-00
        
    [dtini_novidade] => 0000-00-00
        
    [dtfim_novidade] => 0000-00-00
        
    [destaque] => 1
        
    [novidade] => 1
        
    [promocao] => 1
        
    [preco_promocao] => 0
        
    [preco] => 406
        
    [img_p] => 
        [
    img_g] => 
        [
    ficheiro] => 
        [
    marca] => 3
        
    [nome] => Olympus C-765UZ
        
    [caracteristicas] =>     


        [
    descricao] => 
        [
    ficheiro_desc] => temp[ficheiro_desc]
    )



             
    $categoria    = array(
                    
    "0"=>"- escolha uma opção -",
                    
    "1"=>"Ligeiro passageiros",
                    
    "2"=>"Ligeiro mercadorias",
                    
    "3"=>"Pesados"
                    
    );
          
    $carrocaria   = array(
                    
    "0"=>"- escolha uma opção -",
                    
    "1"=>"Cabrios / Roadster",
                    
    "2"=>"Todo-o-terreno / Pick-up",
                    
    "3"=>"Citadinos",
                    
    "4"=>"Limousine",
                    
    "5"=>"Desportivo / Coupé",
                    
    "6"=>"SUV / Monovolume",
                    
    "7"=>"Sem carta condução",
                    
    "8"=>"Clássico",
                    
    "9"=>"Outra",
                    );
          
    $portas       = array(
                    
    "0"=>"- escolha uma opção -",
                    
    "1"=>"Duas",
                    
    "2"=>"Três",
                    
    "3"=>"Quatro",
                    
    "4"=>"Cinco"
                    
    );
          
    $combustivel  = array(
                    
    "0"=>"- escolha uma opção -",
                    
    "1"=>"Gasolina",
                    
    "2"=>"Gasóleo",
                    
    "3"=>"GPL",
                    
    "4"=>"Híbrido",
                    
    "5"=>"Eléctrico",
                    
    "6"=>"Biodiesel",
                    
    "7"=>"Álcool",
                    );
          
    $caixa        = array(
                    
    "0"=>"- escolha uma opção -",
                    
    "1"=>"Manual",
                    
    "2"=>"Automática",
                    
    "3"=>"Semi-automática");
          
    $traccao      = array(
                    
    "0"=>"- escolha uma opção -",
                    
    "1"=>"Dianteira",
                    
    "2"=>"Traseira",
                    
    "3"=>"Integral"
                    
    );
          
    $estado       = array(
                    
    "0"=>"- escolha uma opção -",
                    
    "1"=>"Novo",
                    
    "2"=>"Semi-novo",
                    
    "3"=>"Usado"
                    
    );
          
    $garantia     = array("0"=>"- escolha uma opção -",
                    
    "1"=>"3 Meses",
                    
    "2"=>"6 Meses",
                    
    "3"=>"9 Meses",
                    
    "4"=>"12 Meses",
                    
    "5"=>"18 Meses",
                    
    "6"=>"24 Meses",
                    
    "7"=>"36 Meses",);    


          foreach( array(
    "portas","garantia","estado","traccao","caixa","combustivel","categoria","carrocaria") as $each ){
            
    //      $$each = $$each[$res[0][$each]] ;
            
    $k =  $res[0][$each];
            
    $kk = $$each ;
            $
    $each $kk[$k];
          } 
    well the part that dont work is the comment line, i think it should work right ?
    those 3 lines below are working, need some replys guys
    Last edited by kaydara; Sep 28, 2006, 10:48 AM.
    There are only 10 types of people in the world: Those who understand binary, and those who don't.
    Wich one are you ?

  • #2
    comments are not implemented by php
    Free php image upload script
    Personal web developing blog

    Comment


    • #3
      Originally posted by kreoton View Post
      comments are not implemented by php
      well i was talking about that line dont work uncoment... lol
      dont really know what you think about it
      There are only 10 types of people in the world: Those who understand binary, and those who don't.
      Wich one are you ?

      Comment


      • #4
        In order to use variable variables with arrays, you have to resolve an ambiguity problem. That is, if you write $$each[$res[0][$each]] then the parser needs to know if you meant to use $each[$res[0][$each]] as a variable, or if you wanted $$each as the variable and then the [$res[0][$each]] index from that variable. The syntax for resolving this ambiguity is: ${$each[$res[0][$each]]} for the first case and ${$each}[$res[0][$each]] for the second.

        Comment


        • #5
          5* solved my doubt thanks
          There are only 10 types of people in the world: Those who understand binary, and those who don't.
          Wich one are you ?

          Comment

          Working...
          X