Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7277893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:48:08+00:00 2026-05-28T22:48:08+00:00

How would I join these two strings and create random link based on the

  • 0

How would I join these two strings and create random link based on the entry list.

// Add a link and the associated image //
$adlink1="http://www.****.com/sale.php";
$adlinkpic1="http://www.***-cdn.com/blogAssets/ad/1.jpg";
$adlink2="http://www.*****.com/sale.php";
$adlinkpic2="http://www.**-cdn.com/blogAssets/ad/2.jpg";
$adlink3="http://www.**.com/product.php?prodref=564_white&ref=AddSphere";
$adlinkpic3="http://www.**-cdn.com/blogAssets/ad/3.jpg";
$adlink4="http://www.**.com/wedding-boutique.php";
$adlinkpic4="http://www.**-cdn.com/blogAssets/ad/4.jpg";
$adlink5="http://www.**.com/made-to-measure-service.php";
$adlinkpic5="http://www.**-cdn.com/blogAssets/ad/5.jpg";

// SHOW ONE AD LINK

srand ((double) microtime() * 1000000);
$adlink[] + $adlinkpic[] = rand(0,count($quotes)-1);
echo "<a href='$adlink'><img src='$adlinkpic' />";

// SHOW TWO AD LINKS /cannot be same

// code here
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T22:48:08+00:00Added an answer on May 28, 2026 at 10:48 pm

    It is easy to put all of your links in an (associative) array then use array functions to manipulate them:

    <?php
    $ad = array(
        array(
            "url" => "http://www.****.com/sale.",
            "img" => "http://www.***-cdn.com/blogAssets/ad/1.jpg"
        ),
        array(
            "url" => "http://www.*****.com/sale.",
            "img" => "http://www.**-cdn.com/blogAssets/ad/2.jpg"
        ),
        array(
            "url" => "http://www.**.com/product.php",
            "img" => "http://www.**-cdn.com/blogAssets/ad/3.jpg"
        ),
        array(
            "url" => "http://www.**.com/wedding-boutique.",
            "img" => "http://www.**-cdn.com/blogAssets/ad/4.jpg"
        ),
        array(
            "url" => "http://www.**.com/made-to-measure-service.",
            "img" => "http://www.**-cdn.com/blogAssets/ad/5.jpg"
        )
        // more ads
    );
    
    $id = array_rand($ad); // choose a random index from the array
    echo "<a href=\"{$ad[$id]['url']}\"><img src=\"{$ad[$id]['img']}\" /></a>\n";
    unset($ad[$id]);       // remove the chosen one so that it is not displayed on next pass
    
    $id = array_rand($ad);
    echo "<a href=\"{$ad[$id]['url']}\"><img src=\"{$ad[$id]['img']}\" /></a>\n";
    unset($ad[$id]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two lists based on the same class. I would like one list
Using Django's built in models, how would one create a triple-join between three models.
With of these two approaches would you prefer: trying to find the right data-types
I have two strings, and I would like to test if they are anagrams
How do I do a join that would return me results similar to- SELECT
Which query would run faster? SELECT * FROM topic_info LEFT JOIN topic_data ON topic_info.id
The tool I'm developing would do a thing similar to when you join Facebook
I have a materialized view of a complex join, which I would like to
This has always confused me. It seems like this would be nicer: ["Hello", "world"].join("-")
this call my $th = threads->create(\&print, Hello thread World!\n); $th->join(); works fine. But as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.