Quantcast
Channel: how to create and concatenate dynamic variables in PHP? - Stack Overflow
Browsing all 5 articles
Browse latest View live

Answer by Davide Berra for how to create and concatenate dynamic variables in...

Yes you can. Just use brackets. Look at this example:<?php$one = 1;$suffix_one = "_".$one;$suffix_two = "_2";$base_1 = "VALUE ONE";$base_2 = "VALUE TWO";echo ${"base".$suffix_one}." ,...

View Article



Answer by Sean McSomething for how to create and concatenate dynamic...

Whenever somebody says "dynamic variables" it's a big red flag. You can do them but it's a bad idea 99% of the time. What you're probably looking for is an array. If you write:$menus =...

View Article

Answer by moonwave99 for how to create and concatenate dynamic variables in PHP?

You can use curly brackets for that:${'menu' . $i}but I strongly advise you just to echo the stuff you need inside the loop.Plus, mysql_* functions are deprecated - go either the PDO or the mysqli way...

View Article

Answer by user1941719 for how to create and concatenate dynamic variables in...

Why not use arrays instead?$menu[$i] = "\n\t$('#menu_" . $i . "').hover(function () {";

View Article

how to create and concatenate dynamic variables in PHP?

In this php code, during a while loop, I was hoping to use later 3 variables called $menu_1, $menu_2, and $menu_3. Is this possible in PHP?while($parent_row = mysql_fetch_array($parent_result)){ $menu_...

View Article

Browsing all 5 articles
Browse latest View live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>