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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:00:55+00:00 2026-06-01T23:00:55+00:00

So my code here: $featurecollection = (FeatureCollection); $test[] = array ( type => $featurecollection,

  • 0

So my code here:

    $featurecollection = ("FeatureCollection");

        $test[] = array (
        "type" => $featurecollection,
        $features[] = array($images)

    );

   file_put_contents($cache,json_encode($test));

results in the following json:

[
 {
  "type":"feature",
  "0":[
     [
        {
           "title":"some title",
           "src":"value",
           "lat":"value",
           "lon":"value"
        },
        {
           "title":"some title",
             ...

But I need to nest things differently and I’m perplexed on how the php array should be constructed in order to get a result like:

{
"type":"FeatureCollection",
 "features":[

  {
     "type":"Feature",
     "geometry":{
        "coordinates":[
           -94.34885,
           39.35757
        ],
        "type":"Point"
     },
     "properties":{
        "latitude":39.35757,
        "title":"Kearney",
        "id":919,
        "description":"I REALLY need new #converse, lol. I've had these for three years. So #destroyed ! :( Oh well. Can't wait to get a new pair and put my #rainbow laces through. #gay #gaypride #bi #proud #pride #colors #shoes #allstar #supporting ",
        "longitude":-94.34885,
        "user":"trena1echo5",
        "image":"http://images.instagram.com/media/2011/09/09/ddeb9bb508c94f2b8ff848a2d2cd3ece_7.jpg",
        "instagram_id":211443415
     }
  },

What would the php array look like for that? I’m thrown off by the way everything is nested but still has a key value.

  • 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-01T23:00:56+00:00Added an answer on June 1, 2026 at 11:00 pm

    Here’s how I’d represent that in PHP:

    array(
        'type' => 'FeatureCollection',
        'features' => array(
            array(
                'type' => 'Feature',
                'geometry' => array(
                    'coordinates' => array(-94.34885, 39.35757),
                    'type' => 'Point'
                ), // geometry
                'properties' => array(
                    // latitude, longitude, id etc.
                ) // properties
            ), // end of first feature
            array( ... ), // etc.
        ) // features
    )
    

    So to get that structure, each feature has to be an associative array of:

    • type,
    • geometry – an associative array of:
      • coordinates – an indexed array of values,
      • type
    • properties – an associative array of values like latitude, longitude, id etc.

    It’s times like these when I prefer languages that distinguish between lists (array(1, 2, 3)) and dictionaries or maps (array('a' => 1, 'b' => 2)).

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

Sidebar

Related Questions

I have this code here, which is intended to allow any type of arguments:
Trying to truncate some code here and running into a problem: <script type=text/javascript> $(function()
Some code here, I want store mysql query result into an array with php,
See this code here: class test { int n; int *j; public: test(int m)
enter code here I have the following code to build select menus dynamically: $j(#id).load('create_menu.cgi',
CODE HERE: http://jsfiddle.net/B7Y43/ Hello fello programmers, I have the following situation: My PHP-script generates
Consider the following code: Here is my price calculator controller header file. #import <Foundation/Foundation.h>
I run this code here <html> <script type=text/javascript src=lib/jquery-ui-1.8.21.custom.min.js></script> <script src=http://127.0.0.1:5984/_utils/script/jquery.couch.js></script> <!--<script type=text/javascript src=lib/jquery-1.7.2.js></script>-->
enter code here I have a table on SQL server 2005 with bigint primary
The code here is X++. I know very little about it, though I am

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.