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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:02:29+00:00 2026-05-30T19:02:29+00:00

Quick overview: trying to build a gallery with a string from $_GET (‘foo’), which

  • 0

Quick overview: trying to build a gallery with a string from $_GET (‘foo’), which was passed via AJAX and then generate a small list from that, with title and description.

Is it possible for an array to have 3 elements? In the foreach here it generates list items that use ‘foo’, and then a title and description follow, but I don’t know how to pick out the proper/associated title/description, the one that relates to ‘foo’. Below is what I have:

<?php function generateProject() {


$proj = $_GET['proj'];
$valid_proj = array("deadawesome", "chimaera", "manifesto");
if (!in_array($proj, $valid_proj)) {
}

echo '<div id="proj-wrapper">';
echo '<div id="proj">';
echo '<ul id="'.$proj.'">';

$imgs = glob("../images/portfolio/$proj/*.jpg");

foreach ($imgs as $picture) {
  // Get only the base filename
  $picture = basename($picture);

  // Then build the <li>
  echo '<li><a href="javascript:void(0);"><img src="../images/portfolio/'.$proj.'/'.$picture.'">';
  echo '</li>';
}

echo '</ul>';
echo '</div>';
echo '</div>';

echo '<div class="description">'.$projTitle.' <span class="slash">&nbsp;/&nbsp;</span>'.$projDesc.'</div>';

} ?>

    <?php
               generateProject();
    ?>

Would it be possible to make an array like this, and then find the one that matches ‘foo’ and give the following two values $projTitle and $projDesc?

$projTitles = array('foo' => 'FooTitle' => 'The description for Foo.',
                    'bar' => 'BarTitle' => 'The description for Bar.',
                    'presto' => 'PrestoTitle' => 'The description for Presto.'
                );
  • 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-30T19:02:30+00:00Added an answer on May 30, 2026 at 7:02 pm

    You want an array of associative arrays:

    $projects = array(
      array(
        'id' => 'foo', 
        'title' => 'FooTitle',
        'decription' => 'The description for Foo.'
      ),
      array(
        'id' => 'bar',
        'title' => 'BarTitle',
        'description' => 'The description for Bar.'
      ),
      array(
        'id' => 'presto',
        'title' => 'PrestoTitle',
        'description' => 'The description for Presto.'
      )
    );
    

    You can then loop through it and access the attributes of each array element like so:

    foreach($projects as $project) {
      $id = $project['id'];
      $title = $project['title'];
      $description = $project['description'];
    
      echo "($id) $title - $description";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a quick overview that shows the upcoming calendar week. I
As a quick overview: I'm trying to make a game of pool using Box2D
Quick overview Trying to insert a Business Object using ObjectDataSource (on a GridView) Get
Just to give you a quick overview, just trying to create somewhat of a
Here is a quick overview of the controllers functionality in most of the application:
I'm having trouble swapping Short Description (Quick Overview) with Additional Information (Attributes) Here's an
I'd like to get a quick overview of available solutions (libraries, ...) that allow
Could someone give me a quick overview of the pros and cons of using
The quick overview is this: for my web app I can write most of
Please read here and here to get a quick overview of my problem and

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.