Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
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!
 
 
Register now for full access!
Old 05-16-2008, 07:03 AM Re: Simple array question, adding new values
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 05-18-2008, 03:52 AM Re: Simple array question, adding new values
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.12475 seconds with 12 queries