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

  • Home
  • SEARCH
  • 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 9217453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:38:14+00:00 2026-06-18T02:38:14+00:00

I have this script to generate static html pages for each store location the

  • 0

I have this script to generate static html pages for each store location the company has from a .xls list, then the script encodes urls after store location based on a keyword string.

as it is currently:

keyword_string = "key1 key2 key3 key4 key5";

function urlX($location) {
        return $this->xURL($location).'/'.urlencode($this->keyword_string).'.html';
    }

How can I make it read 2 or even 3 variations of the keyword_string and randomize the html urlencode?

  • 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-06-18T02:38:15+00:00Added an answer on June 18, 2026 at 2:38 am

    This will create truly random links. If you wish to have a set number of keyword_string sets (ie: keyword_string_1 = “key1 key2 key3”, keyword_string_2 = “key2 key3 key1”, etc…) and choose a random set to attach to each location, this method can be used on a more simple scale. There are probably several ways to speed this up as well.

    $keyword_string = "key1 key2 key3 key4 key5";
    
    function urlX($location) {
       global $keyword_string;
       $keyword_string = @explode(" ", $keyword_string);
       if(is_array($keyword_string)){
          $total = count($keyword_string);
          $random_keys = Array();
          for($i=0; $i<$total; $i++){
             $new = rand(0,$total-1);
             while(in_array($new,$random_keys)){
                $new = rand(0,$total-1);
             }
             array_push($random_keys, $new);
          }
       }
       $page = "";
       foreach($random_keys as $key){
          $page .= $keyword_string[$key] . " ";
       }
    
       return $location . "/" . urlencode(trim($page)) . ".html";
    
    }
    

    ADDED NEW:

    Here’s the above code adapted to a set amount of random strings. You can pre-load additional strings and add them to the end of the $keyword_string Array.

    $keyword_string_1 = "key1 key2 key3 key4 key5";
    $keyword_string_2 = "key2 key3 key4 key5 key1";
    $keyword_string_3 = "key3 key4 key5 key1 key2";
    
    /// ADD MORE HERE IF YOU LIKE
    $keyword_string = Array($keyword_string_1, $keyword_string_2, $keyword_string_3); 
    
    function urlX($location) {
       global $keyword_string;
       if(is_array($keyword_string)){
          $total = count($keyword_string);
          $random_keys = Array();
          $page = $keyword_string[rand(0,$total-1)];
       }
       return $location . "/" . urlencode(trim($page)) . ".html";
    }
    
    print urlX("http://www.google.com"); /// SIMPLE CALL TO NEW FUNCTION urlX()
    

    ADDED NEW:

    $keyword_string_1 = "key1 key2 key3 key4 key5";
    $keyword_string_2 = "key2 key3 key4 key5 key1";
    $keyword_string_3 = "key3 key4 key5 key1 key2";
    
    function urlX($location) {
    global $keyword_string_1, $keyword_string_2, $keyword_string_3;    
    
        if($location == "http://www.url1.com"){ /// CHANGE THESE TO ACTUAL URLS
            return $location . "/" . urlencode($keyword_string_1) . ".html";
        }else if($location == "http://www.url2.com"){
            return $location . "/" . urlencode($keyword_string_2) . ".html";
        }else if($location == "http://www.url3.com"){
            return $location . "/" . urlencode($keyword_string_3) . ".html";
        }else{
            return false;
        }
    
    }
    
    print urlX("http://www.url1.com");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this script to generate an XML file for an RSS feed. Works
I have this script in the head of my index.html. I want different scripts
I have the following script which works as long as the are static html
I have a php script that randomly generates an image. Something like this: <?php
I have this script that run to fix my menu bar to the browser
I have this script and need to be able to call the $play variable
I have this script set up that echoes all relevant users in a database
I have this script: #!/var/home/cherry/opt/perl use Test::More; use DBI; use Test::mysqld; use Data::Dumper; my
I have this script $('head').append('<link rel=stylesheet href=css/file1.css type=text/css />'); $('head').append('<link rel=stylesheet href=css/jquery.jscrollpane.css type=text/css />');
I have this script http://jsfiddle.net/gphp/ZMmRv/4/ I have two events: 1 - the div is

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.