Skip to content
Advertisement

Tag: arrays

Organizing array Iteration generated from nested loops PHP

I have a loop that fetches data from an excel file using phpspreadsheet. data fetching has no problem, but what I want to do is organize the data to a multi-dimensional array then convert it to JSON so I can access it through javascript. here’s the code: when I run this code, it shows this text: Now I want to

Array data manipulations PHP

I get from my DB data in format like this: Each of array inside has a key: “id”. It mostly look values from 1 to 3. I would like to create a new array based on this “ids” that would look like this: I`ve been trying to do it like this: And that would work, but it doesn`t look good

Echo specific value of a key of an array generated from an XML

I have the following code: That returns the following result: Now I want to echo the value of “CHANGEDATE”, but echo $array[“note”][“RESPONSE”][“CHANGE”][“TEST”][“CHANGEBY”]; returns nothing. Answer There’s no need to go to JSON, you can use your SimpleXML object directly: However, if you really want/need to, the root element note needs to be skipped: Demo: https://3v4l.org/fbTpB

Create Json array from mysql data

I need a bit of help, i have this code: which is returning and i need to return like this: Could someone helping me? I search everywhere but i don’t see how to adjust array to get needed structure Answer You’re adding an extra array layer with the []. Change the code to this:

Filter API response with PHP

Not sure what issue was with first pastebin code, here is another attempt. I am connecting to Vimeo Live API, in doing so the response is huge > 500kb in total – I have an example with only one object here -> there are over 20 it returns. I have a better idea of what Im doing in JS than

Displaying php mysqli query result with one to many relationship

Current: Process Skill Process A Skill_1 Process A Skill_2 Process A Skill_3 Process B Skill_1 Process B Skill_2 Expected Result: Process Skill Process A Skill_1, Skill_2, Skill_3 Process B Skill_1, Skill_2 Sample SQL: Need help how to rearrange my one to many relationship table. Tried using array “$array= array($row[‘skill_req’]) ” but does not recognize the skill_req variable. Answer You’re looking

How to encode json array inside foreach loop using Php

I am working with Php and Rest Api, i am trying encode data (fetching from database) using foreach loop,but data is not displaying as expected,”result” is showing three time instead of one,Here is my current code Here is my current output But i want “result” should display one time and other data (image) display multiple times (using loop) Answer Actually,

Getting value of an array inside two arrays

I’m trying to get the value of the array, but I just cant quite get to it. I’m trying with a foreach loop and with key and values. But I can’t get it right. I’m working with wordpress custom field, and I’m trying to retrieve product ID, so that I can manipulate website data. This is the array: And I’m

Advertisement