Jump to content

11Tami

Members
  • Posts

    329
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

11Tami's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Thanks a lot you guys, pdkv you lost me that time. The only $get I see is at the end, the arrays are named something else aren't they? Please let me know, thank you very much.
  2. Thanks both of you. Priti, what does the 1 do here? I dont know how to try it. I also tried these, this returns the file file1.txt on every page load correctly and never shows the text "test1". <?php $one[1] = "<span style='color: rgb(70,0,0)'>test1</span>"; $one[2] = "file1.txt"; $two1 = preg_grep('/(?:<span)/', $one); $two2 = preg_grep('/(?:<span)/', $one, PREG_GREP_INVERT); $rand1 = $two1[array_rand($two1)]; $rand2 = $two2[array_rand($two2)]; $file = file_get_contents($rand2); $get = $rand1 + $file; echo $get; ?> .....This only brings back the word "Array" on every page load and nothing else. Is there anyway I can grab onto both? Please let me know, thank you very much. <?php $one[1] = "<span style='color: rgb(70,0,0)'>test1</span>"; $one[2] = "file1.txt"; $two1 = preg_grep('/(?:<span)/', $one); $two2 = preg_grep('/(?:<span)/', $one, PREG_GREP_INVERT); $rand1 = $two1[array_rand($two1)]; $rand2 = $two2[array_rand($two2)]; $file = file_get_contents($rand2); $get = array_merge($rand1,$file); echo $get; ?>
  3. Hello, how would I pick an item from these 2 fields randomly, instead of one at a time? For example this picks an item randomly from both $one1 $one2 separately. How can I choose randomly from both of them instead? So that I only have one result at the end instead of 2? Please let me know, thank you very much. <?php $one= "<span style='color: rgb(70,0,0)'>test1</span>"; $one[3] = "file1.txt"; $one1 = preg_grep('/(?:<span)/', $one); $one2 = preg_grep('/(?:<span)/', $one, PREG_GREP_INVERT); $get1 = $one1[array_rand($one1)]; $get2 = $one2[array_rand($one2)]; $get3 = file_get_contents($get2); echo $get1; echo $get3; ?>
  4. For instance I tried adding this at the bottom as well like those right above it. Doesn't work. $get1 = $title2[$nbr2]; $get2 = $img2[$nbr2];
  5. Sorry about that everything froze, I couldn't finish my post. I have what I just listed above and I can't get it to show whats in $title2 and $img2 arrays. Everything I try doesn't work. Please let me know how to fix this. Thank you very much.
  6. Sorry for the numbers. Ok thanks a lot, its almost there now. Its showing whats in array title1 and img1 and matching them now but its not showing the rest. I have this. <? php $title1[1] = "title1"; $title1[2] = "title2"; $title2[3] = "title3"; $title2[4] = "title4"; $img1[1] = "http://upload.wikimedia.org/wikipedia/commons/thumb/9/9f/BahnhofBludenz.JPG/120px-BahnhofBludenz.JPG"; $img1[2] = "http://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/Korean_stew-Budae_jjigae-01.jpg/120px-Korean_stew-Budae_jjigae-01.jpg"; $img2[3] = "http://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Basilica_Cistern%2C_Constantinople.jpg/120px-Basilica_Cistern%2C_Constantinople.jpg"; $img2[4] = "http://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/A330-200F.jpg/120px-A330-200F.jpg"; if(isset($_COOKIE["array"]) && $_COOKIE["array"]=="two"){ setcookie("array", "one", time()+60*60*24*180); $nbr1 = mt_rand(1, count($title2)); $nbr2 = mt_rand(1, count($img2)); }else{ setcookie("array", "two", time()+60*60*24*180); $nbr1 = mt_rand(1, count($title1)); $nbr2 = mt_rand(3, count($img1)); } $get1 = $title1[$nbr1]; $get2 = $img1[$nbr1]; echo "<img title='$get1' src='$get2' border='0'>"; ?>
  7. Hello, this pulls an image with a title on every next page load. Problem is when it pulls image one I need it to also pull "title 1" and when it pulls image 3 I need it to pull "title 3" right now its not doing that. Right now its sticking whatever title it wants in with the images. How can I get to match the arrays while its also pulling something randomly? Please let me know, thank you very much. <?php $title1[1] = "title1"; $title1[2] = "title2"; $title2[3] = "title3"; $title2[3] = "title3"; $img1[1] = "http://upload.wikimedia.org/wikipedia/commons/thumb/9/9f/BahnhofBludenz.JPG/120px-BahnhofBludenz.JPG"; $img1[2] = "http://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/Korean_stew-Budae_jjigae-01.jpg/120px-Korean_stew-Budae_jjigae-01.jpg"; $img2[3] = "http://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Basilica_Cistern%2C_Constantinople.jpg/120px-Basilica_Cistern%2C_Constantinople.jpg"; $img2[4] = "http://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/A330-200F.jpg/120px-A330-200F.jpg"; if(isset($_COOKIE["array"]) && $_COOKIE["array"]=="two"){ setcookie("array", "one", time()+60*60*24*180); $get2 = $title2[array_rand($title2)]; $get3 = $img2[array_rand($image2)]; }else{ setcookie("array", "two", time()+60*60*24*180); $get2 = $title1[array_rand($title1)]; $get3 = $img1[array_rand($image1)]; } echo "<img title='$get2' src='$get3' border='0'>"; ?>
  8. Hello, how can I include two PHP variables in an image src, depending on which variable I will be using at the time? For example: <?php $image[1] = "http://store.officeworld.com/ProductImages/united/standard/MOW36113_1_1.JPG"; $image[2] = "https://store.officeworld.com/productimages/united/thumbnails/HAM122549_1_1_100.jpg"; $image[4] = "https://store.officeworld.com/productimages/united/thumbnails/A0001856.JPG"; $image[5] = "https://store.officeworld.com/productimages/united/thumbnails/HEWQ1396A_1_1_100.jpg"; $get1 = rand(1,2); $get2 = rand(3,4); echo "<img src='$image[$get1($get2)]' >"; ?> This following part from the above script I need help with: echo "<img src='$image[$get1($get2)]' >"; Sometimes I will only be using $get1 from the array, and other times I will only be using $get2 from the array, depending on what a database inserts into the image source. How can I have the src hold both $get1 and $get2 variables at the same time? The way I have it above says it cannot hold both. Please let me know, thank you very much.
  9. This works fine alone but when it goes into a web page or is included into a web page from another page with a php include, it quits working. It gives header errors. It doesn't seem to like new cookies set near the echos, which is a problem because the echos need to go in the body of the page so people can see their results. Does anyone know how I can set the cookies without getting the page header errors? Please let me know, thank you very much. <?php $one = Array(); $one[1] = "test1"; $one[2] = "test2"; $two = Array(); $two[5] = "test5"; $two[6] = "test6"; if(isset($_COOKIE["array"]) && $_COOKIE["array"]=="two"){ setcookie("array", "one", time()+60*60*24*180); echo $two[array_rand($two)]; }else{ setcookie("array", "two", time()+60*60*24*180); echo $one[array_rand($one)]; } ?>
  10. You have been most helpful to me on this, I really appreciate it and will send you a special thank you. I'm trying this but the echo's still aren't appearing, anyone know why? Please let me know, thank you very much. <?php setcookie("a", $getone, time()+60*60*24*180); $one = Array(); $one[1] = "test1"; $one[2] = "test2"; $two = Array(); $two[1] = "test5"; $two[2] = "test6"; $getone = array_rand($one); $gettwo = array_rand($two); if(isset($_COOKIE['a'])){setcookie("b", $gettwo, time()+60*60*24*180); echo $two[$gettwo];} if(isset($_COOKIE['b'])){setcookie("a", $getone, time()+60*60*24*180); echo $one[$getone];} ?>
  11. How do I get the cookie to remember which array it pulled from the first page load so it knows it should pull from the other array on the next page load? There are only two arrays included. Please let me know, thank you very much. <?php setcookie("a", $get1, time()+60*60*24*180); setcookie("b", $get2, time()+60*60*24*180); $one = Array(); $one[1] = "test1"; $one[2] = "test2"; $two = Array(); $two[1] = "test5"; $two[2] = "test6"; $getone = array_rand($one); $gettwo = array_rand($two); if(isset($_COOKIE['a']) && $getone){ echo $two[$gettwo];} if(isset($_COOKIE['b']) && $gettwo){ echo $one[$getone];} ?>
  12. I'm bringing it back to basics first to get the first part working, then I'll try to get the second working after that so here's what I have. PHP Code: <? php $one = Array(); $one[1] = "test1"; $one[2] = "test2"; $one[3] = "test3"; $one[4] = "test4"; $get = array_rand($one); echo $get; ?> Instead of showing "test1" ect. its only showing 1,2,3, or 4. Anyone know why? Thanks a lot.
  13. Anyone know? I can add the cookie to it, I just need to set up the rest. Thanks.
  14. Thanks a lot, I need it so that if it picked from array one randomly the first time, next time it will pick from array two. How do I write that? Please let me know, thank you very much. <?php ini_set('error_reporting', 8191); ini_set('display_startup_errors', 1); ini_set('display_errors', 1); $one = Array(); $one[1] = "test"; $two = Array(); $two[1] = "test2"; $get = shuffle($one,$two); echo $get; ?>
  15. Thanks a lot for the help but I think I still need a cookie. Cause it needs to remember what it saw the time before until the next visit, not to forget soon after the browser closes. I just hadn't put the expiration in the first one yet. Unless someone can tell me why I'm wrong. Please keep all the ideas coming, I really need a fix, thank you very much.
×
×
  • 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.