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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:21:19+00:00 2026-06-15T10:21:19+00:00

I am trying to create various, standard HTML list styles from PHP arrays for

  • 0

I am trying to create various, standard HTML list styles from PHP arrays for a movie database I’m building as part of my final year project at university, however I’m having some trouble accessing/understanding how to do this. I’ve got the relevant data from the various APIs I’m using, but I’d like to create the entire list dynamically, dropping in the correct bits of information where appropriate.

Details of the two list styles I’m looking to create are below.

List style 1 – Character/Cast details

For the first style of list, I’d like to create it as:

<ul>
   <li>Cast name - Character name</li>
   <li>Cast name - Character name</li>
   <li>etc. etc.</li>
<ul>

My data set direct from the array looks like this:

Array
(

[abridged_cast] => Array
    (
        [0] => Array
            (
                [name] => Daniel Craig
                [id] => 162687443
                [characters] => Array
                    (
                        [0] => James Bond
                    )

            )

        [1] => Array
            (
                [name] => Javier Bardem
                [id] => 162661456
                [characters] => Array
                    (
                        [0] => Silva
                    )

            )

        [2] => Array
            (
                [name] => Judi Dench
                [id] => 162652435
                [characters] => Array
                    (
                        [0] => M
                    )

            )

        [3] => Array
            (
                [name] => Ralph Fiennes
                [id] => 162653681
                [characters] => Array
                    (
                        [0] => Gareth Mallory
                        [1] => Mallory
                    )

            )

        [4] => Array
            (
                [name] => Naomie Harris
                [id] => 162705781
                [characters] => Array
                    (
                        [0] => Eve
                    )

            )

    )

In the above example, there’s five cast members w/ their respective character names, however on some other examples, there’s more or less than five, so, ideally, I’d want the system to know however many cast members were given and create a list for each, up to a maximum of 10 names.

List style 2 – Videos

Similar to the last style, however this list will hopefully look like this:

<ul>
    <li><a href='<http://youtube.com/<dynamically generated URL direct to the clip>'><img src='dynamically generated URL to the clip's thumbnail' /></a></li>
    <li>same as above...</li>
</ul>

The source array looks like this:

Array
(
[id] => 37724
[youtube] => Array
    (
        [0] => Array
            (
                [name] => Trailer
                [size] => HQ
                [source] => 24mTIE4D9JM
            )

        [1] => Array
            (
                [name] => Official Trailer
                [size] => HD
                [source] => 6kw1UVovByw
            )

        [2] => Array
            (
                [name] => Trailer 1
                [size] => HD
                [source] => 1Uyjf5Pp0Ko
            )

        [3] => Array
            (
                [name] => Trailer 2
                [size] => HD
                [source] => 5Ejo9_3iUpw
            )

    )

)

Apologies for the length of this post, thanks in advance to anyone who may be able to assist!

  • 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-15T10:21:19+00:00Added an answer on June 15, 2026 at 10:21 am

    The thing you are looking for is called a foreach loop. For your first example it would look something like this:

    foreach($dataSet['abridged_cast'] as $castMember){
        echo '<li>'.$castMember['name'].'-'.implode(', ', $castMember['characters']). '</li>';
    }
    

    Now this example is purely illustratory though it most definetely be the begginers approach.
    Still, I would strongly recommend investigating MVC patterns and PHP frameworks, like for example YII. If deployed and configured right YII with all its goodness should make all the repetitive work done for you here.

    I’ve seen that your question contains two parts, though I am not willing to write a sample for the second one, since it is practically the same as the first and with proper attention – you will get on track and figure it out.

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

Sidebar

Related Questions

I'm trying to create a system in PHP/Zend that can gather emails from various
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I am trying to create a nested JSON that has data from various db
I'm trying to create matrices of various distance/association functions in R. I have a
I am trying to create an android app that will connect to various web
I am trying to create a class with various methods that will need to
I'm trying to create a transparent png image and layer various other pngs and
I'm trying to create a particular effect - where essentially various elements move around
I'm trying to create a function that will loop through an array of various
I am trying to create a liquid 3 column area within a list item.

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.