ssuubb Posted August 12, 2009 Share Posted August 12, 2009 hi everyone - my apologies for what may be a simple question, but i just cant get my head around it! below is a script which i am using, and it is working properly when printing to the browser like so: print("".$urls[$day]); but i need to use the $urls[$day] output in the following query_posts command. normal usage of the query_posts commad would be the following: query_posts('p=34') but i am using the script below to specify the argument based on the day of the month. ie. on the 12th day of the month $urls[$day] would output p=34 my problem is that i dont know how to specify the $urls[$day] argument: query_posts('.$urls[$day].') the above makes sense to me, but i obviously have no idea! any help would be greeted with real unadulterated gratitude from myself. thanks for reading! <?php // Data here $day1='data1'; $day2='data2'; $day3='data3'; $day4='data4'; $day5='data5'; $day6='data6'; $day7='data7'; $day8='data8'; $day9='data9'; $day10='data10'; $day11='data11'; $day12='p=34'; $day13='data13'; $day14='data14'; $day15='data15'; $day16='data16'; $day17='data17'; $day18='data18'; $day19='data19'; $day20='data20'; $day21='data21'; $day22='data22'; $day23='data23'; $day24='data24'; $day25='data25'; $day26='data26'; $day27='data27'; $day28='data28'; $day29='data29'; $day30='data30'; $day31='data31'; //Make the array $urls=array($day1, $day2, $day3, $day4, $day5, $day6, $day6, $day7, $day8, $day9, $day10, $day11, $day12, $day13, $day14, $day15, $day16, $day17, $day18, $day19, $day20, $day21, $day22, $day23, $day24, $day25, $day26, $day27, $day28, $day29, $day30, $day31); //Get day of the month $day=date("j"); //Print in broswer query_posts('.$urls[$day]'); ?> Quote Link to comment Share on other sites More sharing options...
Alex Posted August 12, 2009 Share Posted August 12, 2009 I'm not sure I understand your question completely. But just by looking at the code I'm guessing you want this: query_posts($urls[$day]); Anything inbetween single quotes will be parsed as a string. So instead of the value of $urls[$day], it would literally be the string '$urls[$day]', and you had a period in there Quote Link to comment Share on other sites More sharing options...
ssuubb Posted August 12, 2009 Author Share Posted August 12, 2009 Thank you so much Alex! I really appreciate you assistance Many thanks Quote Link to comment Share on other sites More sharing options...
Alex Posted August 12, 2009 Share Posted August 12, 2009 Please press the "Solved" Button on the bottom left of the page. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.