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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:19:20+00:00 2026-05-13T18:19:20+00:00

I am building a small gallery that will only have 20 or so images

  • 0

I am building a small gallery that will only have 20 or so images in it. I’d like to have this data stored somewhere (even in the PHP file itself) and so am looking at ways of encoding the data as a literal or resource file.

In JavaScript, I would use notation resembling (from memory):

var albums = [
  { name='Album 1', photos=['photo1.jpg', 'photo2.jpg'] },
  { name='Album 2', photos=['photo3.jpg', 'photo4.jpg'] }
]

This is JSON, in essence.

I suppose JavaScript is more dynamic than PHP and so this is not possible. Is there a simple alternative, perhaps using XML and binding to some classes?

I’m a complete PHP novice, so please don’t assume any knowledge in your answer.

  • 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-13T18:19:21+00:00Added an answer on May 13, 2026 at 6:19 pm

    If you just have some constant data that you want to store in a PHP file, you can use the same thing as you did in Javascript : just declare a PHP array.

    Something like this should do the trick :

    $albums = array(
        array(
            'name' => "Album 1", 
            'photos' => array('photo1.jpg', 'photo2.jpg'), 
        ), 
        array(
            'name' => "Album 2", 
            'photos' => array('photo3.jpg', 'photo4.jpg'), 
        ), 
    );
    

    And, then, you just can work with the $albums array.

    Of course, it’s not easy to update, you have to write some valid PHP code — but if you only have a couple of images, like you said, it should not be that hard to manage.

    Another solution would be to store the data in an external file (in XML or JSON, for instance), and use something like simplexml_load_file or json_decode to read it.

    But it means a bit more work — so maybe not that necessary in your case ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: I'm building a small application that will be run daily, pulling data from
I am building small app that will only display products in various categories. And
First, I only have experience building small-medium sized websites with php so forgive me
I'm building this small java applet in which I need a JPanel which will
I'm building a small website which will have FBA enabled (SqlMembershipProvider) and I want
I'm building a small web based media player that has a basic structure like
We are building a small web application in Rails that will allow clients to
I'm building small blog-like system for school. I need to store some data in
I´m building a small application with Jquery and PHP. Jquery (index.html) adds Form Fields
I am building a small activex control. I understood that activex cannot call 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.