Have you tried this?

function writeJs($prefix)
{
        $thevar = $prefix."_fade";
        if($databaseresult->$thevar == 1)
        {
                etc...
        }
}


[ Now playing: "Muy, Muy Temprano" by Los Fabulosos Cadillacs from "La  
Luz Del Ritmo" ]

On 13/01/2009, at 10:54 AM, matt_thomson wrote:


Does anyone know if this is possible?

//$prefix equals 'main' or 'lightbox', both strings
function writeJs($prefix)
{
        //if the function is called with 'main' as the
        //prefix, I want to check the
        //var $databaseresult->main_fade, if
        //'lightbox' is the prefix, I want to check the
        //var $databaseresult->lightbox_fade

      //this will throw an error, but it shows what I mean
       if($databaseresult->.$prefix.'_fade' == 1)
        {
                //write some js for the main gallery
                //or lightbox gallery
        }
}
//I call this function twice, once to write some js for a gallery,
//and another time to write some similar js for the lightbox bit

Thanks,

Matt.



--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---

Reply via email to