Reply
Simple array question, adding new values
Old 05-16-2008, 03:27 AM Simple array question, adding new values
Arenlor's Avatar
Ultra Talker

Posts: 463
Name: Jerod Lycett
Location: /home/arenlor
I have an array with an arbritary number of values in it that is set by several factor. So in one case the array could have 5 the next time it could have 12. The values are added one at a time. The code I'm doing is running a foreach loop on an array which parses a series files and looks for a certain line, each file can contain the line numerous times or not even contain it at all. The number of files it looks through also changes each time. I'm sure it's just that I'm tired that I can't figure out how to do this as my brain is telling me that there is something simple I'm missing and that's all.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
When You Register, These Ads Go Away!
Old 05-16-2008, 06:03 AM Re: Simple array question, adding new values
tripy's Avatar
Fetchez la vache!

Posts: 2,055
Name: Thierry
Location: In the void
I don't really understand what your question is?
Do you need direction to make this, do you have some code that raise an error at some place ?
And could you try to summarize a bit please?

I you want to add values to an array, simply use
PHP Code:
$ary[]="new value"
This will do. If your array have more than 1 dimension though, you will need something like
PHP Code:
$idx=sizeof($ary);
$ary[$idx]['dim1']='value 1';
$ary[$idx]['dim2']='value 2';
//... and so on 
As the sizeof() return the number of elements (starting at 1) and the PHP index starts at 0, sizeof return directly the next available index value.
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 05-18-2008, 02:52 AM Re: Simple array question, adding new values
Arenlor's Avatar
Ultra Talker

Posts: 463
Name: Jerod Lycett
Location: /home/arenlor
Thankyou that was what I needed. It was one dimensional, just blanked out on how to do it.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Reply     « Reply to Simple array question, adding new values
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12441 seconds with 12 queries