0

I'm trying to get the data in an array in javascript.

here's my arrayProgram in javascript:

 [0] => Array (
 [Program] => Array (
 [event_name] => Event Daily
 [keyword] => KVIP SHOWTIME
 [start_date] => 2017年04月07日 12:00:00
 [end_date] => 2017年04月03日 15:00:00
 [location] => Studio 1
 [slots] => 10
 [event_color] => #9a9aff
 [is_allday] => 1
 [repeat_program] => daily-weekly
 [repeat_every] => 1
 [repeat_days] => ,1,2,3,4,5,6
 [repeat_yearly] => 0
 [is_end] => 0
 )
 )
[1] => Array (
 [Program] => Array (
 [event_name] => NEWS
 [keyword] => KVIP NEWS
 [start_date] => 2017年04月30日 05:30:00
 [end_date] => 2017年04月01日 19:00:00
 [location] => Studio 4
 [slots] => 05
 [event_color] => #fb8979
 [is_allday] => 1
 [repeat_program] => monthly
 [repeat_every] => 0
 [repeat_days] => 
 )
 )
[2] => Array (
 [Program] => Array (
 [event_name] => ASAP
 [keyword] => KVIP ASAP
 [start_date] => 2017年12月31日 12:00:00
 [end_date] => 2017年04月01日 15:00:00
 [location] => Studio 10
 [slots] => 16
 [event_color] => #9a9aff
 [is_allday] => 1
 [repeat_program] => yearly
 [repeat_every] => 0
 [repeat_days] => 
 )
 )

how can I extract the data using a for loop? I tried using $.each but it doesn't work for me. Can someone please help me?

asked Apr 1, 2017 at 7:48

1 Answer 1

1

You can loop by using for statement:

var arr = [/* your array data here*/];
for (var i = 0; i < arr.length; i++)
{
 console.log( arr[i]['Program']['event_name'] );
 console.log( arr[i]['Program']['keyword'] );
 // ... use arr[i]['Program'][...] to access other attribute
}
answered Apr 1, 2017 at 7:55
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.