Jump to content

Recommended Posts

here's what i want to do:

 

<?php
$tempID = "random";
$a = "\$humor_video_";
str_replace('$a', $a, $b);
$tempModded = $b.$tempID."_modded_day2";
?>

where

$humor_video_random_modded_day2 = "Dec 3";

so i want to be able to echo $tempModded; and return "Dec 3"

 

is this possible? and if so, how? i'm pulling my hair out here... basically, i'm in transition from flat files to mySQL, and getting stuff working in the "in between" stages..

 

TIA.

Link to comment
https://forums.phpfreaks.com/topic/123364-solved-nesting-variables/
Share on other sites

not exactly...

 

basically, "random" is a column in a row in a table (sounds a lot like the house that jack built....)

other columns in the same table include "zp" "snl", etc...

 

i need a good way to get

$humor_video_[columnContent]_modded_day

 

however necessary

 

So:

echo $humor_video_random_modded_day //print "Jun 2"
echo $humor_video_zp_modded_day //print "Jan 19"
echo $humor_video_snl_modded_day //print "Dec 5"

 

or whatever those variables happen to be....

ok... i'll try again :)

 

i have a file "updated.php" that has when all categories have been updated last with code like (for simplicity's sake..):

<?php
$humor_video_random_modded_day = "Jun 2";
$humor_video_zp_modded_day = "Jan 19";
$humor_video_snl_modded_day = "Dec 2";
?>

 

i have a table that has in a column the content: random, zp, snl; each in a different row.

 

i have a for() loop that goes through and gets all the content from that table, and echos some info.

 

i want to be able to dynamically get the information in the updates.php site using the content in the table (random, zp, snl) in the variable...

 

so: $lastMod = "$humor_video_".$forloopArray[$i][4]."_modded_day";

 

but (obviously) the above code doesn't work, so i'm looking for a piece that will...

 

i'm hoping that this explains it a little better...

can you post the code you're speaking of?

 

$tempID = "random";
$frontVar = "humor_video_";
$tempModded = ${$frontVar.$tempID."_modded_day2"};

 

is all I can really come up with from your original question... this will set $tempModded to the value held in $humor_video_random_modded_day2 (not that it's good practice).

haha.. actually, i'm using filemtime() now to get the date, and in the future, date will be stored in the db, so the entire function will be different, so there won't need to be comments, because it will be re-written from scratch, basically.. ;)

 

thanks again!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.