I have this code :
Code: Select all
<?PHP
$a = 'df';
$b_df = 'Woow';
print $b_$a;
?>Moderator: General Moderators
Code: Select all
<?PHP
$a = 'df';
$b_df = 'Woow';
print $b_$a;
?>Code: Select all
$a = 'df';
$b = array('df'=>'Woow');
print $b[$a];Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
<?php
$a = 'df';
$b_df = 'Woow';
print ${'b_' . $a};
?>Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
<?php
$a = 'bc';
$d_bc = 'Woow';
echo $d_{$a};
?>I tried that before, it doesn't workEverah wrote:Untested, but i should work.Code: Select all
<?php $a = 'bc'; $d_bc = 'Woow'; echo $d_{$a}; ?>
james.aimonetti wrote:Everah | Please useCode: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]What you need this for, I have no idea. But see http://www.php.net/manual/en/language.v ... riable.php for how to do variable variables.Code: Select all
<?php $a = 'df'; $b_df = 'Woow'; print ${'b_' . $a}; ?>
Everah | Please useCode: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color][/quote] many thanks bro. it works 100%