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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:33:28+00:00 2026-06-03T13:33:28+00:00

I have an array in the following format: var markers = [ [‘Title’, 15.102253,

  • 0

I have an array in the following format:

var markers = [
    ['Title', 15.102253, 38.0505243, 'Description', 1], 
    ['Another Title', 15.102253, 38.0505243, 'Another Description', 2],
    ['Title 3', 15.102253, 38.0505243, 'Description 3', 3], 
];

I then have a query string being passed to the page (m=1,2), which being comma separated, is then split to create an array like the following:

['1', '2']

What I need to do is find all ‘markers’ where the ID (markers[i][4]) comes from the query string.

What would be the best way to achieve this? Ideally I want to create a 3rd array in the same format as ‘markers’ but only showing the results from the query string.

Any help would be greatly appreciated.

Thanks

  • 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-03T13:33:29+00:00Added an answer on June 3, 2026 at 1:33 pm

    One option is to use nested loops:

    var markers = [
        ['Title', 15.102253, 38.0505243, 'Description', 1], 
        ['Another Title', 15.102253, 38.0505243, 'Another Description', 2],
        ['Title 3', 15.102253, 38.0505243, 'Description 3', 3], 
    ];
    var search = ['1', '2'];
    var result = [];
    
    for (var i = 0; i < search.length; i++)
        for (var j = 0; j < markers.length; j++)
            if (search[i] == markers[j][4]) {
                result.push(markers[j]);
                break;
            }
    
    console.log(result);
    

    DEMO: http://jsfiddle.net/3TErD/

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

Sidebar

Related Questions

I have array in following format. I want to convert it into another format
I have the following array. <cfset ItemHasUsers = arrayNew(1)> <cfloop query=qReadData> <cfset ItemHasUsers[qReadData.currentrow][ID] =
I have the following array as3 example: var arrayDefinitionsargsAmfPhp:Array = new Array(); arrayDefinitionsargsAmfPhp['tabela'] =
I have an array of the following format: array 0 => array 1335541286 =>
I am learning mootools. I have an array in following format. I want to
I have an array with the following format: [NSArray arrayWithObjects: [NSArray arrayWithObjects:@number,@name,@date,@about,nil], [NSArray arrayWithObjects:@number,@name,@date,@about,nil],
I have a large array in this format: var cars = [{brand:Honda,year:2002},{brand:Toyota,year:2000},{brand:Subaru,year:2009}]; The array
I have been given an array in the following format and need to put
I have the following MySQL query, and PHP code to format the Count result
I have an array in the following format: array( 0 => array(1, 5), 1

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.