hackalive Posted April 11, 2012 Share Posted April 11, 2012 Hi guys I am putting together an array in PHP for encoding into JSON but how do I make it be like "date": [ and not "date": { ?? Not sure even what to call it or look into. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/260732-invoke/ Share on other sites More sharing options...
hackalive Posted April 11, 2012 Author Share Posted April 11, 2012 More specifically I need to mimick this: { "timeline": { "headline":"FifteenTwo", "type":"default", "startDate":"2012", "text":"<span class='c1'>A blog of</span> <span class='c2'>Innovation</span>", "asset": { "media":"idea.jpg", "credit":"", "caption":"<b>There's a way to do it better - find it.</b> <i>Thomas Edison</i>" }, "date": [ { "startDate":"2012,4,11", "headline":"Where good ideas come ferom", "text":"We all operate in two contrasting modes, which might be called open and closed. The open mode is more relaxed, more receptive, more exploratory, more democratic, more playful and more humorous. The closed mode is the tighter, more rigid, more hierarchical, more tunnel-visioned. Most people, unfortunately spend most of their time in the closed mode. Not that the closed mode cannot be helpful. If you are leaping a ravine, the moment of takeoff is a bad time for considering alternative strategies. When you charge the enemy machine-gun post, don't waste energy trying to see the funny side of it. Do it in the 'closed' mode. But the moment the action is over, try to return to the 'open' mode - to open your mind again to all the feedback from our action that enables us to tell whether the action has been successful, or whether further action is need to improve on what we have done. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent.", "asset": { "media":"http://youtu.be/NugRZGDbPFU", "credit":"", "caption":"One of our most innovative, popular thinkers takes on-in exhilarating style-one of our key questions: Where do good ideas come from?" } }, { "startDate":"2012,9,27", "headline":"Digital world expo 2012", "text":"Digital World Expo is an annual conference highlighting emerging interactive and digital media channels, with in-depth workshops for attendees and new business for exhibitors and sponsors. Digital World Expo is an engaging event with a cutting edge curriculum, special events and a high-energy, innovative exhibit hall.", "asset": { "media":"http://www.thengashow.com/images/mirage-hotel-las-vegas/mirage_hotel.jpg", "credit":"", "caption":"" } }, { "startDate":"2013,4,11", "headline":"Where good ideas come from", "text":"We all operate in two contrasting modes, which might be called open and closed. The open mode is more relaxed, more receptive, more exploratory, more democratic, more playful and more humorous. The closed mode is the tighter, more rigid, more hierarchical, more tunnel-visioned. Most people, unfortunately spend most of their time in the closed mode. Not that the closed mode cannot be helpful. If you are leaping a ravine, the moment of takeoff is a bad time for considering alternative strategies. When you charge the enemy machine-gun post, don't waste energy trying to see the funny side of it. Do it in the 'closed' mode. But the moment the action is over, try to return to the 'open' mode - to open your mind again to all the feedback from our action that enables us to tell whether the action has been successful, or whether further action is need to improve on what we have done. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent." } ] } } But am unable to get it to work. Got the bit up to date okay, just not that and beyond (the bit below). "date": [ { "startDate":"2012,4,11", "headline":"Where good ideas come ferom", "text":"We all operate in two contrasting modes, which might be called open and closed. The open mode is more relaxed, more receptive, more exploratory, more democratic, more playful and more humorous. The closed mode is the tighter, more rigid, more hierarchical, more tunnel-visioned. Most people, unfortunately spend most of their time in the closed mode. Not that the closed mode cannot be helpful. If you are leaping a ravine, the moment of takeoff is a bad time for considering alternative strategies. When you charge the enemy machine-gun post, don't waste energy trying to see the funny side of it. Do it in the 'closed' mode. But the moment the action is over, try to return to the 'open' mode - to open your mind again to all the feedback from our action that enables us to tell whether the action has been successful, or whether further action is need to improve on what we have done. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent.", "asset": { "media":"http://youtu.be/NugRZGDbPFU", "credit":"", "caption":"One of our most innovative, popular thinkers takes on-in exhilarating style-one of our key questions: Where do good ideas come from?" } }, { "startDate":"2012,9,27", "headline":"Digital world expo 2012", "text":"Digital World Expo is an annual conference highlighting emerging interactive and digital media channels, with in-depth workshops for attendees and new business for exhibitors and sponsors. Digital World Expo is an engaging event with a cutting edge curriculum, special events and a high-energy, innovative exhibit hall.", "asset": { "media":"http://www.thengashow.com/images/mirage-hotel-las-vegas/mirage_hotel.jpg", "credit":"", "caption":"" } }, { "startDate":"2013,4,11", "headline":"Where good ideas come from", "text":"We all operate in two contrasting modes, which might be called open and closed. The open mode is more relaxed, more receptive, more exploratory, more democratic, more playful and more humorous. The closed mode is the tighter, more rigid, more hierarchical, more tunnel-visioned. Most people, unfortunately spend most of their time in the closed mode. Not that the closed mode cannot be helpful. If you are leaping a ravine, the moment of takeoff is a bad time for considering alternative strategies. When you charge the enemy machine-gun post, don't waste energy trying to see the funny side of it. Do it in the 'closed' mode. But the moment the action is over, try to return to the 'open' mode - to open your mind again to all the feedback from our action that enables us to tell whether the action has been successful, or whether further action is need to improve on what we have done. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent. In other words, we must return to the open mode, because in that mode we are the most aware, most receptive, most creative, and therefore at our most intelligent." } ] Quote Link to comment https://forums.phpfreaks.com/topic/260732-invoke/#findComment-1336330 Share on other sites More sharing options...
trq Posted April 11, 2012 Share Posted April 11, 2012 [] is an array in JavaScript while {} is an object (more like a has actually). A numerically indexed array will encode into [] in php while an associative array will encode into {} Quote Link to comment https://forums.phpfreaks.com/topic/260732-invoke/#findComment-1336343 Share on other sites More sharing options...
hackalive Posted April 11, 2012 Author Share Posted April 11, 2012 so will doing the non JS way break my code? (probably will yeah). So how do I do the JS way then? Quote Link to comment https://forums.phpfreaks.com/topic/260732-invoke/#findComment-1336345 Share on other sites More sharing options...
trq Posted April 11, 2012 Share Posted April 11, 2012 Sorry, I edited my post. See above. Quote Link to comment https://forums.phpfreaks.com/topic/260732-invoke/#findComment-1336347 Share on other sites More sharing options...
hackalive Posted April 11, 2012 Author Share Posted April 11, 2012 Thanks thorpe. Problem solved Cheers Quote Link to comment https://forums.phpfreaks.com/topic/260732-invoke/#findComment-1336351 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.