473,385 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

adding using $i++

anfetienne
424 256MB
i didnt know what to call this. but yeah lol

if $i = 0 and somewhere in my code i use $i++ will $i start at 0 or 1?

if it starts at 1 can i set $i = -1 so when it starts counting it starts at 0?
Jul 23 '09 #1
10 4183
Canabeez
126 100+
@anfetienne
It's pretty simple, $i starts from whatever you set it in the beginning... using $i++ is the same as doing $i = $i + 1;
Jul 23 '09 #2
Dormilich
8,658 Expert Mod 8TB
or putting it in other words:
$i++ post increment
++$i pre increment
Jul 23 '09 #3
anfetienne
424 256MB
ok thanks....i've fixed it....

i had two $i on my page and it was messing with my loop so it always started from 1....i've changed one of them and its output starts at 0 like it should
Jul 23 '09 #4
Markus
6,050 Expert 4TB
@Dormilich
To expand a little on that: the post-increment will assign the current value of the right hand variable* to the left hand variable*, and then increment the right hand variable's value; the pre-increment operator will do the opposite: increment the right hand, and then assign that to the left hand.

*Variables is just an example - it can be other things, such as an expression.
Jul 23 '09 #5
anfetienne
424 256MB
thanks again guys......

much appreciated
Jul 23 '09 #6
dlite922
1,584 Expert 1GB
Don't forget decrement!
$i--
--$i


And multiplication
$i**
Division
**$i

Dan


Yes that last two are a joke
Jul 23 '09 #7
Markus
6,050 Expert 4TB
@dlite922
Damn you! I thought you were serious about the last two, and I was about to reach for the manual to learn something new! :P
Jul 23 '09 #8
Dheeraj Joshi
1,123 Expert 1GB
Hey it would have been great, if $i** does $i*$i(Now it wont do ofcourse).

We could easily multiply a number by itself..
Jul 24 '09 #9
Canabeez
126 100+
@dheerajjoshim
Bet you've already tried that one... :)
Jul 24 '09 #10
Dheeraj Joshi
1,123 Expert 1GB
Nop... Never tried it..
Jul 24 '09 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

34
by: Adam Hartshorne | last post by:
Hi All, I have the following problem, and I would be extremely grateful if somebody would be kind enough to suggest an efficient solution to it. I create an instance of a Class A, and...
5
by: Paul | last post by:
Hi I have a table that currently has 466 columns and about 700,000 records. Adding a new DEFAULT column to this table takes a long time. It it a lot faster to recreate the table with the new...
9
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows security to manage the permissions. Why reinvent...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
47
by: Pierre Barbier de Reuille | last post by:
Please, note that I am entirely open for every points on this proposal (which I do not dare yet to call PEP). Abstract ======== This proposal suggests to add symbols into Python. Symbols...
17
by: Sri | last post by:
How do you add an n-bit number in C? Regards, Sri
14
by: Paul_Madden via DotNetMonster.com | last post by:
Basically I have a listbox to which I add simple STRING items- I have a progress bar which I increment whenever I populate another portion of the complete set of items I wish to add. What I observe...
9
by: Kadett | last post by:
Hi all, I have following problem: I'm creating a ListView (Details) control at run-time and filling it with some records (let's say 10 000). This operation seems to be quite fast, but when I call...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.