/    Sign up×
Community /Pin to ProfileBookmark

Hi I have proble related my array index.

I am getting my result like this

0=>1,xyz,06/09/2015
1=>2,pqr,07/09/2015….

and I need result like this

id=>1
name=>xyz
date=>06/09/2015
id=>2
name=>pqr
date=>07/09/2015

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmJun 09.2015 — Uh, is there some code behind this or are we just supposed to guess about what you are doing?
Copy linkTweet thisAlerts:
@NogDogJun 09.2015 — [code=php]
$data = array();
foreach($yourArray as $row) {
$parts = explode(',', $row);
$data[$parts[0]] = array(
'name' => $parts[1],
'date' => $parts[2]
);
}
[/code]

However, as the array gets larger, this all becomes more and more of a memory hog, so it will not scale well, in which case there may be better ways to do this (e.g. by iterating through a query result set or wherever the data is coming from).
Copy linkTweet thisAlerts:
@rootJun 10.2015 — Also, it helps to wrap any code elements, segments in forum tags, as you will find on ALL web forums, this is a defacto standard, some boards disable tags, this site doesn't..! So please use them, see NogDogs example... thats [b][p[/b][b]hp][/b]...code in here...[b][/p[/b][b]hp][/b].
×

Success!

Help @hardikspider123 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...