PHP: How to set the value of a variable through another variable?How can I prevent SQL injection in PHP?Convert HTML + CSS to PDF with PHP?How do I make a redirect in PHP?How do I get PHP errors to display?How to get the client IP address in PHPHow do you parse and process HTML/XML in PHP?Reference — What does this symbol mean in PHP?PHP array delete by value (not key)How does PHP 'foreach' actually work?Reference - What does this error mean in PHP?

Average Two Letters

Why do Muslim refugees seek asylum in Europe and not in rich countries in the Middle East?

Paint Exterior Door that is in Sun

Higher Gravity vs Higher Air Density

Doing chemistry under water?

Why does the media continue to hide the identity of the Trump-Ukraine whistle blower when they have already been outed?

Do magic staves require the wielder to have the spells on their list in order to cast them?

white marks on garage ceiling

What is `stty line NUMBER` even doing?

Joining elements of a list if those elements are in between two whitespaces

Where do I put nobles/royalty in a scifi military

What color is a wolf's coat?

How do you deal with someone who is nosy, projects their feelings about career, and gives unsolicited advice in that area?

Did any astronauts on a mission complain about waking up?

How do I experimentally measure the surface area of a rock?

Getting data from Seagate ST-238R drive

What's the difference between words "tongue" and "lingua"?

Is it possible to get reverse life insurance?

Why do airline tickets have titles in addition to names?

Why don't all humans have absolute pitch?

Definition of NMR peak

Solving Fizz Buzz using LINQ in C#

What's the most rewarding path?

Reverse color of overlapping points?



PHP: How to set the value of a variable through another variable?


How can I prevent SQL injection in PHP?Convert HTML + CSS to PDF with PHP?How do I make a redirect in PHP?How do I get PHP errors to display?How to get the client IP address in PHPHow do you parse and process HTML/XML in PHP?Reference — What does this symbol mean in PHP?PHP array delete by value (not key)How does PHP 'foreach' actually work?Reference - What does this error mean in PHP?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









3

















I have a variable that calls an item, but what I have to display is the description of his category. So the structure I figured out is something like this willing that writing $item1 in $var1 it displays "Bla Bla Bla" (the value of $cat1):



$var1 = $item1;
$item1 = $cat1;
$cat1 = 'Bla Bla Bla';


Believe or not it doesn't work :-)
I am a novice with php, sorry to ask stupid questions! And thank you so much to help!










share|improve this question




























  • Hi, not sure exectly what you are trying to achieve

    – RiggsFolly
    Mar 28 at 22:11












  • are you maybe trying something like $var1->cat1 ? just guessing here

    – jonathan Heindl
    Mar 28 at 22:13











  • Yes and my english does not help (I am Italian)... indeed I would like to write <?php echo $var1; ?> in my page and display "Bla Bla Bla" but I need to use those 3 variables

    – Foorio
    Mar 28 at 22:14











  • why do you need 3 variables ?

    – jonathan Heindl
    Mar 28 at 22:15











  • Because it is the product, the category and the family... so when I set the product I need also to display the Family Description

    – Foorio
    Mar 28 at 22:16

















3

















I have a variable that calls an item, but what I have to display is the description of his category. So the structure I figured out is something like this willing that writing $item1 in $var1 it displays "Bla Bla Bla" (the value of $cat1):



$var1 = $item1;
$item1 = $cat1;
$cat1 = 'Bla Bla Bla';


Believe or not it doesn't work :-)
I am a novice with php, sorry to ask stupid questions! And thank you so much to help!










share|improve this question




























  • Hi, not sure exectly what you are trying to achieve

    – RiggsFolly
    Mar 28 at 22:11












  • are you maybe trying something like $var1->cat1 ? just guessing here

    – jonathan Heindl
    Mar 28 at 22:13











  • Yes and my english does not help (I am Italian)... indeed I would like to write <?php echo $var1; ?> in my page and display "Bla Bla Bla" but I need to use those 3 variables

    – Foorio
    Mar 28 at 22:14











  • why do you need 3 variables ?

    – jonathan Heindl
    Mar 28 at 22:15











  • Because it is the product, the category and the family... so when I set the product I need also to display the Family Description

    – Foorio
    Mar 28 at 22:16













3












3








3








I have a variable that calls an item, but what I have to display is the description of his category. So the structure I figured out is something like this willing that writing $item1 in $var1 it displays "Bla Bla Bla" (the value of $cat1):



$var1 = $item1;
$item1 = $cat1;
$cat1 = 'Bla Bla Bla';


Believe or not it doesn't work :-)
I am a novice with php, sorry to ask stupid questions! And thank you so much to help!










share|improve this question

















I have a variable that calls an item, but what I have to display is the description of his category. So the structure I figured out is something like this willing that writing $item1 in $var1 it displays "Bla Bla Bla" (the value of $cat1):



$var1 = $item1;
$item1 = $cat1;
$cat1 = 'Bla Bla Bla';


Believe or not it doesn't work :-)
I am a novice with php, sorry to ask stupid questions! And thank you so much to help!







php






share|improve this question
















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 22:56









Nik

1,2701 gold badge7 silver badges17 bronze badges




1,2701 gold badge7 silver badges17 bronze badges










asked Mar 28 at 22:10









FoorioFoorio

182 bronze badges




182 bronze badges















  • Hi, not sure exectly what you are trying to achieve

    – RiggsFolly
    Mar 28 at 22:11












  • are you maybe trying something like $var1->cat1 ? just guessing here

    – jonathan Heindl
    Mar 28 at 22:13











  • Yes and my english does not help (I am Italian)... indeed I would like to write <?php echo $var1; ?> in my page and display "Bla Bla Bla" but I need to use those 3 variables

    – Foorio
    Mar 28 at 22:14











  • why do you need 3 variables ?

    – jonathan Heindl
    Mar 28 at 22:15











  • Because it is the product, the category and the family... so when I set the product I need also to display the Family Description

    – Foorio
    Mar 28 at 22:16

















  • Hi, not sure exectly what you are trying to achieve

    – RiggsFolly
    Mar 28 at 22:11












  • are you maybe trying something like $var1->cat1 ? just guessing here

    – jonathan Heindl
    Mar 28 at 22:13











  • Yes and my english does not help (I am Italian)... indeed I would like to write <?php echo $var1; ?> in my page and display "Bla Bla Bla" but I need to use those 3 variables

    – Foorio
    Mar 28 at 22:14











  • why do you need 3 variables ?

    – jonathan Heindl
    Mar 28 at 22:15











  • Because it is the product, the category and the family... so when I set the product I need also to display the Family Description

    – Foorio
    Mar 28 at 22:16
















Hi, not sure exectly what you are trying to achieve

– RiggsFolly
Mar 28 at 22:11






Hi, not sure exectly what you are trying to achieve

– RiggsFolly
Mar 28 at 22:11














are you maybe trying something like $var1->cat1 ? just guessing here

– jonathan Heindl
Mar 28 at 22:13





are you maybe trying something like $var1->cat1 ? just guessing here

– jonathan Heindl
Mar 28 at 22:13













Yes and my english does not help (I am Italian)... indeed I would like to write <?php echo $var1; ?> in my page and display "Bla Bla Bla" but I need to use those 3 variables

– Foorio
Mar 28 at 22:14





Yes and my english does not help (I am Italian)... indeed I would like to write <?php echo $var1; ?> in my page and display "Bla Bla Bla" but I need to use those 3 variables

– Foorio
Mar 28 at 22:14













why do you need 3 variables ?

– jonathan Heindl
Mar 28 at 22:15





why do you need 3 variables ?

– jonathan Heindl
Mar 28 at 22:15













Because it is the product, the category and the family... so when I set the product I need also to display the Family Description

– Foorio
Mar 28 at 22:16





Because it is the product, the category and the family... so when I set the product I need also to display the Family Description

– Foorio
Mar 28 at 22:16












1 Answer
1






active

oldest

votes


















4


















assignation of values in most common programm languajes is up to down (cascade programming style)



$var1 = $item1; <--- at this point $item1 is "empty" or null
$item1 = $cat1; <--- at this point $cat1 is empty too
$cat1 = 'Bla Bla Bla'; <--- here $cat1 take value 'Bla Bla Bla'


so, you have to invert order of assignation like this:



$cat1 = 'Bla Bla Bla';
$item1 = $cat1;
$var1 = $item1;


the output show 'Bla Bla Bla' for $cat1 $item1 and $var1
hope this help.






share|improve this answer




























  • That's great, thank you!

    – Foorio
    Mar 28 at 22:28












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55407627%2fphp-how-to-set-the-value-of-a-variable-through-another-variable%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown


























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4


















assignation of values in most common programm languajes is up to down (cascade programming style)



$var1 = $item1; <--- at this point $item1 is "empty" or null
$item1 = $cat1; <--- at this point $cat1 is empty too
$cat1 = 'Bla Bla Bla'; <--- here $cat1 take value 'Bla Bla Bla'


so, you have to invert order of assignation like this:



$cat1 = 'Bla Bla Bla';
$item1 = $cat1;
$var1 = $item1;


the output show 'Bla Bla Bla' for $cat1 $item1 and $var1
hope this help.






share|improve this answer




























  • That's great, thank you!

    – Foorio
    Mar 28 at 22:28















4


















assignation of values in most common programm languajes is up to down (cascade programming style)



$var1 = $item1; <--- at this point $item1 is "empty" or null
$item1 = $cat1; <--- at this point $cat1 is empty too
$cat1 = 'Bla Bla Bla'; <--- here $cat1 take value 'Bla Bla Bla'


so, you have to invert order of assignation like this:



$cat1 = 'Bla Bla Bla';
$item1 = $cat1;
$var1 = $item1;


the output show 'Bla Bla Bla' for $cat1 $item1 and $var1
hope this help.






share|improve this answer




























  • That's great, thank you!

    – Foorio
    Mar 28 at 22:28













4














4










4









assignation of values in most common programm languajes is up to down (cascade programming style)



$var1 = $item1; <--- at this point $item1 is "empty" or null
$item1 = $cat1; <--- at this point $cat1 is empty too
$cat1 = 'Bla Bla Bla'; <--- here $cat1 take value 'Bla Bla Bla'


so, you have to invert order of assignation like this:



$cat1 = 'Bla Bla Bla';
$item1 = $cat1;
$var1 = $item1;


the output show 'Bla Bla Bla' for $cat1 $item1 and $var1
hope this help.






share|improve this answer
















assignation of values in most common programm languajes is up to down (cascade programming style)



$var1 = $item1; <--- at this point $item1 is "empty" or null
$item1 = $cat1; <--- at this point $cat1 is empty too
$cat1 = 'Bla Bla Bla'; <--- here $cat1 take value 'Bla Bla Bla'


so, you have to invert order of assignation like this:



$cat1 = 'Bla Bla Bla';
$item1 = $cat1;
$var1 = $item1;


the output show 'Bla Bla Bla' for $cat1 $item1 and $var1
hope this help.







share|improve this answer















share|improve this answer




share|improve this answer








edited Mar 29 at 2:00









Alireza Zojaji

5581 gold badge7 silver badges26 bronze badges




5581 gold badge7 silver badges26 bronze badges










answered Mar 28 at 22:24









Sebastian P.Sebastian P.

761 bronze badge




761 bronze badge















  • That's great, thank you!

    – Foorio
    Mar 28 at 22:28

















  • That's great, thank you!

    – Foorio
    Mar 28 at 22:28
















That's great, thank you!

– Foorio
Mar 28 at 22:28





That's great, thank you!

– Foorio
Mar 28 at 22:28




















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55407627%2fphp-how-to-set-the-value-of-a-variable-through-another-variable%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown









Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현