/    Sign up×
Community /Pin to ProfileBookmark

Inserting data into array inside array

Hi all,

how can I insert data into an array inside an array?

I have this array setup already:

[code]array(6) {
[89]=>
array(1) {
[0]=>
string(1) “9”
}
[103]=>
array(1) {
[0]=>
string(1) “3”
}
[102]=>
array(1) {
[0]=>
string(1) “3”
}
[95]=>
array(1) {
[0]=>
string(1) “3”
}
[96]=>
array(1) {
[0]=>
string(1) “3”
}
[97]=>
array(1) {
[0]=>
string(1) “3”
}
}[/code]

How can I insert into row 96 for an example so that it would go from:

[code] [96]=>
array(1) {
[0]=>
string(1) “3”
}[/code]

to

[code] [96]=>
array(3) {
[0]=>
string(1) “3”
[1]=>
string(1) “40”
[2]=>
string(1) “850”
}[/code]

Maybe this is a newbie question … but I just can’t figure it out ?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@abou_hmedJan 23.2008 — how you are building your array?

any way you should you array two dimensions

$array[96][]=3;

.

.

.
Copy linkTweet thisAlerts:
@Mester_PedizJan 28.2008 — Do you allways know witch row you need to update?

If then you just make a function where you input

main array, new value, row num

Then pull out the data from the row into a new array then you can update that and put it back into the main array in the same row num and return it ?

If you don't know the exact row, then you just loop through the main array and find the right row with some if() thingies and do the same as above...

Dunno if there's any way better to do it (prob is) but i would do it like that
×

Success!

Help @trymbill 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 5.25,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...