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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:30:31+00:00 2026-06-08T13:30:31+00:00

I’ve got a simple array working based off the url ie www.example.com/apple/ it places

  • 0

I’ve got a simple array working based off the url ie http://www.example.com/apple/ it places in the apple text where I need it – but I also need an option of pasting in a separate fixed piece of text based off the brand.

IE so I can draw it with $brand_to_use to place in “apple” for example and $brandurl_to_use to draw in “apple.co.uk” where I need it but I’m not sure how to add this to the array based off the original brand.

Thanks

$recognised_brands = array( 
  "apple", 
  "orange", 
  "pear",
  // etc 
); 

$default_brand = $recognised_brands[0]; // defaults brand to apple

$brand_to_use = isset($_GET['brand']) && in_array($_GET['brand'], $recognised_brands) 
  ? $_GET['brand'] 
  : $default_brand;

Pseudo code update example:

recognised brands = 
apple
orange
pear

default brand = recognised brand 0


recognised brandurl =
apple = apple.co.uk
orange = orange.net
pear = pear.com



the brandurl is found from the recognised brands so that in the page content I can reference

brand which will show the text apple at certain places +
brandurl will show the correct brand url related to the brand ie apple.co.uk
  • 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-08T13:30:32+00:00Added an answer on June 8, 2026 at 1:30 pm

    Create your array as a key/value pair and search for a key in the array. The value part of each pair can be an object if you like.

    $recognised_brands = array(  
      "apple" => "http://apple.co.uk/",  
      "orange" => "http://orange.co.uk/",  
      "pear" => "http://pear.co.uk/", 
      // etc  
    );  
    
    reset($recognised_brands);  // reset the internal pointer of the array
    $brand = key($recognised_brands); // fetch the first key from the array
    
    if (isset($_GET['brand'] && array_key_exists(strtolower($_GET['brand']), $recognised_brands))
        $brand = strtolower($_GET['brand']);
    
    $brand_url = $recognised_brands[$brand];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i got an object with contents of html markup in it, for example: string
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a

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.