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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:07:32+00:00 2026-06-13T08:07:32+00:00

$Flight = array ( ‘1’ => array ( ‘5’ => array ( ‘LFID’ =>

  • 0
 $Flight = array
            (
            '1' => array
                (
                '5' => array
                    (
                    'LFID' => '6684',
                    'DepartureDate' => '2012-10-22T12:30:00',
                    'ArrivalDate' => '2012-10-22T14:00:00',
                    'BaseFareAmtInclTax' => '343.50',
                    'ReturnFlightSegmentDetails' =>
                    array
                        (
                        '87' => array
                            (
                            'LFID' => '6647',
                            'DepartureDate' => '2012-10-24T12:25:00',
                            'FareTypeName' => 'Change',
                            'FareTypeID' => '22',
                            'BaseFareAmtInclTax' => '198',
                        )
                    )
                ),
                '10' => array
                    (
                    'LFID' => '6684',
                    'DepartureDate' => '2012-10-23T12:30:00',
                    'ArrivalDate' => '2012-10-23T14:00:00',
                    'BaseFareAmtInclTax' => '243.50',
                    'ReturnFlightSegmentDetails' =>
                    array
                        (
                        '150' => array
                            (
                            'LFID' => '6647',
                            'DepartureDate' => '2012-10-24T12:25:00',
                            'FareTypeName' => 'Change',
                            'FareTypeID' => '22',
                            'BaseFareAmtInclTax' => '198',
                        ),
                        '153' => Array
                            (
                            'LFID' => '6647',
                            'DepartureDate' => '2012-10-26T12:25:00',
                            'FareTypeName' => 'Change',
                            'FareTypeID' => '22',
                            'BaseFareAmtInclTax' => '198',
                        )
                    )
                )
            ),
        );

I have this array from my controller which is passed to my twig where I execute the below code to parse it into a js array:

{% for flight in flights%}
                   var $FlightSegment = new Array();
                  $flight.push({
                        key:"{{ flight.key }}",
                        DepartureDate:"{{flight.DepartureDate}}",
                        ArrivalDate:"{{flight.ArrivalDate}}",
                        Amount:"{{flight.BaseFareAmtInclTax}}",
                        
                     });
                     {% for ReturnFlightSegmentDetails in flight.ReturnFlightSegmentDetails %}
                          $FlightSegment.push({
                                LFID :"{{ReturnFlightSegmentDetails.LFID}}", 
                                DepartureDate:"{{ReturnFlightSegmentDetails.DepartureDate}}",
                                ArrivalDate:"{{ReturnFlightSegmentDetails.BaseFareAmtInclTax}}",
                                Class:"{{ReturnFlightSegmentDetails.FareTypeName}}",
                           });
                      {% endfor %}
                      console.info($FlightSegment);
                    $flight.push({
                        ReturnFlightSegmentDetails :$FlightSegment,
                    });
                {% endfor %} 

The problem is that $flight.length returns 4 instead of 2, the ReturnFlightSegmentDetails is considered like an object instead to be an attribute for a flight.

  • 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-13T08:07:34+00:00Added an answer on June 13, 2026 at 8:07 am

    You need to build the “flight” object differently; there’s really no need for the “$FlightSegment” variable.

    {% for flight in flights%}
        $flight.push({
            key: "{{ flight.key }}",
            DepartureDate: "{{flight.DepartureDate}}",
            ArrivalDate: "{{flight.ArrivalDate}}",
            Amount: "{{flight.BaseFareAmtInclTax}}",
            ReturnFlighSegmentDetails: [
               {% for ReturnFlightSegmentDetails in flight.ReturnFlightSegmentDetails %}
                 {
                    LFID :"{{ReturnFlightSegmentDetails.LFID}}", 
                    DepartureDate:"{{ReturnFlightSegmentDetails.DepartureDate}}",
                    ArrivalDate:"{{ReturnFlightSegmentDetails.BaseFareAmtInclTax}}",
                    Class:"{{ReturnFlightSegmentDetails.FareTypeName}}"
                  }
                   {% if not loop.last } , {% endif }
               {% endfor %}
            ]
           });
     {% endfor %} 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want model the flight of a couple of planes using path data. I
I have a flight reservation program use mssql ,For reserving flights i want to
I am accessing an XML API (flight search comparison) via a PHP Proxy like
I could not integrate the Test Flight sdk in my ios App for crash
I have an application where i show Flight Departure Date and Arrival Date and
I'm writing a simple flight reservation application for one of my homeworks. My flight
A pilot may enter their route of flight into a textbox as: KRIC-KLAX -
Actually in my Project I want to automatically change flight mode and auto rotate
I have the following pseudo-SQL schema: table flight id int primary key date timestamp
I'm developing a line drawing game, similar to Flight Control, Harbor Master, and others

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.