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

  • Home
  • SEARCH
  • 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 8042271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:31:16+00:00 2026-06-05T04:31:16+00:00

I have the following json: http://pastebin.com/uxpWk2CY And I need to split it into a

  • 0

I have the following json:

http://pastebin.com/uxpWk2CY

And I need to split it into a number of arrays depending on the width of the browser.

Here is my javascript:

    var imageArray = jQuery.parseJSON(data);

    var splitArrayInto = jQuery(document).width() / 300;
    splitArrayInto = Math.floor(splitArrayInto);

    var seperateImageArrays = array_fill(0, splitArrayInto);

    for(var i = 0; i < splitArrayInto; i++){
        seperateImageArrays[i % splitArrayInto][i] = imageArray[i];
    }

When I run that, I get

can’t convert undefined to object

seperateImageArrays[i % splitArrayInto][i] = imageArray[i];

Any help is appreciated.

EDIT:
Forgot to add the array_fill function.

//PHP array_fill
function array_fill (start_index, num, mixed_val) {
    var key, tmp_arr = {};

    if (!isNaN(start_index) && !isNaN(num)) {
        for (key = 0; key < num; key++) {
            tmp_arr[(key + start_index)] = mixed_val;
        }
    }

    return tmp_arr;
}
  • 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-05T04:31:18+00:00Added an answer on June 5, 2026 at 4:31 am

    When you call array_fill you’re not passing the third parameter, so all your array elements are set to undefined … and undefined can’t be dereferenced with [i].

    Consider passing [] as the third parameter instead.

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

Sidebar

Related Questions

I have the following JSON: http://pastebin.com/Sh20StJY SO removed the chars on my post, so
I have the following code $curl_handle = curl_init(); $api_url = 'http://api.twitter.com/1/statuses/home_timeline.json'; curl_setopt($curl_handle, CURLOPT_URL, $api_url);
I have the following jQuery (info from here http://www.threelas.com/2012/02/basic-blogger-json-feed-api.html ). the problem i am
I have the following Json collection and I need to represent it as a
I have the following Gemfile: source http://rubygems.org gem 'sinatra', '1.3.2' gem 'json', '1.6.4' And
I have the following JSON: {workspace: { name:Dallas, dataStores:http://.....:8080/geoserver/rest/workspaces/Dallas/datastores.json, coverageStores:http://.....:8080/geoserver/rest/workspaces/Dallas/coveragestores.json, wmsStores:http://....:8080/geoserver/rest/workspaces/Dallas/wmsstores.json}} And I´m trying
I have following jQuery/JS code <script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js></script> <script> $.getJSON(http://example/topics, {}, function(data){ console.log( data
I have the following querystring (where kvks is dynamic): http://api.openkvk.nl/json/SELECT bedrijfsnaam FROM kvk WHERE
I have the following JSON: { recipe: { rating: 19.1623, source_name: Allrecipes, thumb: http://img.punchfork.net/8f7e340c11de66216b5627966e355438_250x250.jpg,
I have the following code: page = Net::HTTP.get_response(URI.parse('http://www.enhancetv.com.au/tvguide/rss/melbournerss.php')).body rescue nil show_info = Hash.from_xml(page).to_json puts

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.