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 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 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; 09-28-2006 at 03:48 PM.
    There are only 10 types of people in the world: Those who understand binary, and those who don't.
    Wich one are you ?

  • #2
    New Coder
    Join Date
    Sep 2006
    Location
    Lithuania
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts
    comments are not implemented by php

  • #3
    New Coder
    Join Date
    Feb 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote 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 ?

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    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.

  • #5
    New Coder
    Join Date
    Feb 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 ?


  •  

    Posting Permissions

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