Try it like this:
function writeJs($prefix) {
$method = $prefix.'_fade';
if($databaseresult->$method == 1) {
}
}
2009/1/13 matt_thomson <[email protected]>:
>
> 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.
> >
>
--
Chris Hope
The Electric Toolbox Ltd
Email: [email protected]
Web: www.electrictoolbox.com
Phone: +64 9 522 9531
Mobile: +64 21 866 529
--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---