Jump to content

etrader

Members
  • Posts

    315
  • Joined

  • Last visited

    Never

Posts posted by etrader

  1. Just out of curiosity; in the first version where the link is generated for each random word as

    <?php
    $titles_array = array("one","two","three","four","five","six","seven","eight","nine","word8","word3","word4","word9","anotherword","hello","funny","great","cool","nice");
    
    shuffle($titles_array);
    $i = 0;
    foreach ($titles_array as $titles => $title) {
    $title = trim($title);
    $make_link = "http://example.com/$title";
    $link = "<a href='$make_link'>$title</a>";
    echo "$link<br />";
        if (++$i == 5) break;
    }
    
    ?>

    we have the same CPU issue? I mean that php reads throughout the file to find a random word?

  2. This is so kind of you. Actually, I made some efforts to modify the code. My problem was to use two 'foreach'. As you see, when we use

    foreach ($titles_array as $titles => $title)

    , we have the chance to use $title for making the url. But when using

    foreach ($links as $make_link)

    , the $title disappears and cannot be used for the link title. The problem is that we cannot have two variables, $links (as a mixture of initial variables: $domain, $tld, and $title) and $title for making the hyperlink.

  3. Sorry for many questions, but I really liked this amazing solution. In the case of

    <?php
    $titles_array = array("one","two","three","four","five","six","seven","eight","nine","word8","word3","word4","word9","anotherword","hello","funny","great","cool","nice");
    
    shuffle($titles_array);
    $i = 0;
    foreach ($titles_array as $titles => $title) {
    $title = trim($title);
    $make_link = "http://example.com/$title";
    $link = "<a href='$make_link'>$title</a>";
    echo "$link<br />";
        if (++$i == 5) break;
    }
    
    ?>

     

    How it is possible to define a list of urls too. I mean having an array file containing

    http://example1.com

    http://example2.com

    http://example3.com

     

    and make links randomly by the urls and words  ::)

×
×
  • 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.