Re: Help with arrays?



In article <de047$44ed9dc3$8259c69c$5289@xxxxxxxxxxxxxxxx>,
"Rik" <luiheidsgoeroe@xxxxxxxxxxx> wrote:

Flaming Corncob wrote:
In article <9c30f$44ed965b$8259c69c$3516@xxxxxxxxxxxxxxxx>,
"Rik" <luiheidsgoeroe@xxxxxxxxxxx> wrote:

Flaming Corncob wrote:
Is there any way to add to an already existing array?

Several, for instance:

1. $array[] = $value;
Will add a numerically indexed value on the end of the array
2. array_push($array, $foo, $bar,...);
Will add an arbitrary amount of variables to the end of the array
3. array_unshift($arraym$foo,$bar,....);
Same as array_push, only to the beginning

And many, many more possibilities, read up on it:
http://www.php.net/manual/en/ref.array.php
http://www.php.net/manual/en/language.types.array.php

Cool. Already stumbled on array_push() but $array is easier. Next I
need to be able to find something in an array and if it's there erase
it. I've tried unset() but that destroys part of the array and when
you add to it after that it doesn't fill in the hole created by
unset..

Is there any reason why you want a continuous numerically indexed array?
Often there is no need.

You could set an empty variable: $array[$key] = '', or use
array_values($array) to return a freshly indexed array.

Looking for a way to store email addresses. I've coded a forum which is
nearing completion.. one of the things I'd like it to be able to do is
allow users to "subscribe" to something and if a new post is made that
they'd be interested in it would notify them. The only way I see of
doing it is for a group or topic to have it's own simple single array to
hold email addresses.
.



Relevant Pages

  • "array unset arrayVar", "unset arrayVar" and traces
    ... thought it would be enough to trace the operation unset on the array ... If an array is deleted by "unset arrayVar", than there is one trace ... But if an array is deleted by "array unset arrayVar", ...
    (comp.lang.tcl)
  • Re: The difference between [array unset] and [unset]
    ... % array unset x foo ... % array set x {foo bar} ...
    (comp.lang.tcl)
  • Re: Cant unset $_GET
    ... >On my page, the user can display tables, created out of a database. ... Altering the $_GET array is a lot like trying ... >after the unset, it shows me that in the $_GET array exists before the ... since the browser does not get to see the ...
    (comp.lang.php)
  • Cleaning Up Array After unset()
    ... The data is stored in a serialized array in the order_data field in the orders table. ... The name is split(to create an array of just the selected items), ... The problem I discovered is that unset leaves the other indices in place, so when I loop through what remains of $old_order ...
    (comp.lang.php)
  • Re: array problem
    ... "arenaTR" wrote ... with a variable size to the array. ... > looking to unset, and that doesn't seem to work. ...
    (comp.lang.tcl)