| | |
Very simple loop array help
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2009
Posts: 27
Reputation:
Solved Threads: 0
Hi guys, I have a very simple question I can't solve because I haven't used arrays.
How can I make a For Loop that increments by 1 and when it does that takes the value and puts it in an array.
So eg.
Loop 1
Array = 1
Loop 2
Array = 2
etc..
I want to check in each loop after the value has been added to the array for a specific value.
Thats all I need. Hope you can help
-Toxikr3
How can I make a For Loop that increments by 1 and when it does that takes the value and puts it in an array.
So eg.
Loop 1
Array = 1
Loop 2
Array = 2
etc..
I want to check in each loop after the value has been added to the array for a specific value.
Thats all I need. Hope you can help
-Toxikr3
0
#2 Oct 18th, 2009
I don't really understand what you're getting at. Have you checked the php online manual?
Could you give more specifics?
What value??
This just adds the numbers 2-17 to the array variable, $myarray.
BTW: there is a short way of doing this, but the above should be easier to understand.
Could you give more specifics?
•
•
•
•
I want to check in each loop after the value has been added to the array for a specific value.
php Syntax (Toggle Plain Text)
$start_no = 2; $end_no = 17; // ... other code? ... $i = $start_no; while($i <= $end_no){ // ... check the value here if you need to BEFORE adding the value ... $myarray[] = $i; // ... check the value here if you need AFTER adding the value ... $i = $i + 1; }
This just adds the numbers 2-17 to the array variable, $myarray.
BTW: there is a short way of doing this, but the above should be easier to understand.
Happy Humbugging Christmas
![]() |
Similar Threads
- how to use ctime ,random function,for loop and array??? (C++)
- Splitting up Strings (Visual Basic 4 / 5 / 6)
- Retrieve data and display in drop down boxes (PHP)
- simple while loop (C++)
- Program with 2 arrays (C++)
- problem creating a for loop for an array (C++)
- Array without twice the same number? (C)
Other Threads in the PHP Forum
- Previous Thread: PHP Popup Window...
- Next Thread: Chat Application
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date development directory display download dynamic echo email error file files filter folder form forms function functions gc_maxlifetime google host href htaccess html image include insert integration ip java javascript joomla limit link login loop mail memmory memory menu mlm mod_rewrite multiple mysql navigation oop parse parsing paypal pdf php problem query radio random recursion regex remote script search server sessions sms snippet soap source space sql structure syntax system table thesishelp tutorial update upload url validation validator variable video web xml youtube






