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 7495313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:01:45+00:00 2026-05-29T18:01:45+00:00

Hmmm how to explain? ;) I think I just let the crappy coding to

  • 0

Hmmm how to explain? 😉 I think I just let the crappy coding to the talking 🙂

Given an array of URL ‘templates (truncated for ease of use)

$default = array(
    "/$market",
    "/$market/catalog/productsaz/",
    "/$market/catalog/products/$artid",
);

and a multidimensional array of markets (truncated for ease of use)

$markets = array(
array(market => "/gb/en", storeid => "storeId=1", langid =>"langId=-1", storenumber=> "001", prodid=> "12345", artid=> "4525412" ),
array(market => "/at/de", storeid => "storeId=2", langid =>"langId=-81", storenumber=> "003", prodid=> "12356", artid=> "8456125" ),
array(market => "/be/nl", storeid => "storeId=19", langid =>"langId=-13", storenumber=> "008", prodid=> "12367", artid=> "4578542" )
);

How do I blend the two together in order to get an array of resolved URL’s for each market.

i.e.

/gb/en
/gb/en/catalog/productsaz/
/gb/en/catalog/products/4525412
/at/de
/at/de/catalog/productsaz/
/at/de/catalog/products/8456125
/be/nl
/be/nl/catalog/productsaz/
/be/nl/catalog/products/4578542

Of course array_merge seems the obvious choice, but I can’t seem to work out how it would work in this case. So I did try a longer hand way, which while it is not efficient, seems like it should work to me but doesn’t (the variables from the markets array don’t seem to resolve)

Here is what I have so far:

function builder($clusterArray,$marketArray,$urlArray) {
if(isset($_POST['server'])) {
    $server = $_POST['server'];
    // DETERMINE THE CLUSTER
    $cluster=false;
    foreach($clusterArray as $n=>$c)
        if(in_array($server,$c)) {
            $cluster=$n;
            break;
        }
    print("Server=" . $server . "and cluster=" . $cluster); //DEBUG
    // DRAW THE TABLE
    //print("<table><tr><th>MARKET</th>");

    // LOOP THROUGH MARKETS AND IDS TO CREATE AN ARRAY OF URL'S 
    $urlsTohit = array();
    $baseurl = "http://$server";
    foreach($marketArray as $mkt) {
        $market = $mkt['market'];
        $storeid = $mkt['storeid'];
        $langid = $mkt['langid'];
        $storenumber = $mkt['storenumber'];
        $prodid = $mkt['prodid'];
        $artid = $mkt['artid'];
        foreach($urlArray as $template){
            array_push($urlsTohit,$baseurl . $template);        
        }
    }
    print_r($urlsTohit); //DEBUG
} else {
    print("Oops! Seems like you forgot to select a server. Please go back and choose a server before clicking on Go!");
}
}

EDIT: According to @Eugen Rieck I have updated my function to be:

function preSurfBuilder($clusterArray,$marketArray,$urlArray) {
if(isset($_POST['server'])) {
    $server = $_POST['server'];
    // DETERMINE THE CLUSTER
    $cluster=false;
    foreach($clusterArray as $n=>$c)
        if(in_array($server,$c)) {
            $cluster=$n;
            break;
        }
    print("Server=" . $server . "and cluster=" . $cluster); //DEBUG
    // DRAW THE TABLE
    //print("<table><tr><th>MARKET</th>");

    // LOOP THROUGH MARKETS AND IDS TO CREATE AN ARRAY OF URL'S 
    $baseurl = "http://$server";
    $result=array();
    foreach ($urlArray as $u) {
        foreach ($marketArray as $m) {
            $uu=$u;
            foreach ($m as $k=>$v)
                $uu=str_replace('$'.$k, $v, $uu);
            $result[]=$uu;
            }
        }
    print_r($result);
} else {
    print("Oops! Seems like you forgot to select a server. Please go back and choose a server before clicking on Go!");
}
}

and the output is something like (truncated):

Array ( [0] => / [1] => / [2] => / [3] => / [4] => / [5] => / [6] => / [7] => / [8] => / [9] => / [10] => / [11] => / [12] => / [13] => / [14] => / [15] => / [16] => / [17] => / [18] => / [19] => / [20] => / [21] => / [22] => / [23] => / [24] => / [25] => / [26] => / [27] => / [28] => / [29] => / [30] => / [31] => / [32] => / [33] => / [34] => / [35] => / [36] => / [37] => //catalog/productsaz/ [38] => //catalog/productsaz/ [39] => //catalog/productsaz/ [40] => //catalog/productsaz/ [41] => //catalog/productsaz/ [42] => //catalog/productsaz/ [43] => //catalog/productsaz/ [44] => //catalog/productsaz/ [45] => //catalog/productsaz/ [46] => //catalog/productsaz/ [47] => //catalog/productsaz/ [48] => //catalog/productsaz/ [49] => //catalog/productsaz/ [50] => //catalog/productsaz/ [51] => //catalog/productsaz/ [52] => //catalog/productsaz/ [53] => //catalog/productsaz/ [54] => //catalog/productsaz/ [55] => //catalog/productsaz/ [56] => //catalog/productsaz/ [57] => //catalog/productsaz/ [58] => //catalog/productsaz/ [59] => //catalog/productsaz/ [60] => //catalog/productsaz/ [61] => //catalog/productsaz/ [62] => //catalog/productsaz/ [63] => //catalog/productsaz/ [64] => //catalog/productsaz/ [65] => //catalog/productsaz/ [66] => //catalog/productsaz/ [67] => //catalog/productsaz/ [68] => //catalog/productsaz/ [69] => //catalog/productsaz/ [70] => //catalog/productsaz/ [71] => //catalog/productsaz/ [72] => //catalog/productsaz/ [73] => //catalog/p
  • 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-29T18:01:47+00:00Added an answer on May 29, 2026 at 6:01 pm
    $result=array();
    foreach ($default as $d) {
      foreach ($markets as $m) {
        $dd=$d;
        foreach ($m as $k=>$v)
          $dd=str_replace('$'.$k, $v, $dd);
        $result[]=$dd;
      }
    }
    
    print_r($result);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was working on a program,that I need to support new additions. Hmmm. Let
Hmmm...crappy question, but I didn't know how to phrase this: I have a sweet
Hmmm... the Java Iterator<T> has a remove() method but not a replace(T replacement) method.
Hmmm. Consider this program, whose goal is to figure out the best way to
Hmmm...strange problems... I'm making a form to upload syllabi. Basically, someone go search for
Well, there are other ways (hmmm... or rather working ways) to do it, but
I am coding a little script to save some data from Internet every single
Hmmm I don't know how to clearly state the title. hopefully the following explanation
Directory is like so: test.html blah hmmm Inside blah we have all the applet
Ok, I've fired up my debugger in Chrome and I've placed a breakpoint just

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.