Change a number -1
Moderator: General Moderators
Change a number -1
How would I change a number minus 1?
I have a number 99 and I need to take away 1 to make it 98
please help.
I have a number 99 and I need to take away 1 to make it 98
please help.
Code: Select all
$myVar = 99;
$myVar--;
echo $myVar;-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Aren't questions like that illegal? 
I'm sorry, but that is the most trivial programming related question I have ever heard...
If you couldn't figure that out it's because you haven't even glanced at a book or article, etc...
If your under 16...I forgive you...and apologize and suggest you pick up a book...if not...then I just kicked you in the shins
Cheers
I'm sorry, but that is the most trivial programming related question I have ever heard...
If you couldn't figure that out it's because you haven't even glanced at a book or article, etc...
If your under 16...I forgive you...and apologize and suggest you pick up a book...if not...then I just kicked you in the shins
Cheers
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Not everyone here is a coding genius. Heck, some don't even have a grasp on the logic. I'd agree that the OP probably didn't do a lick of searching for the answer before posting. But cut him some slack. Most of us around here (myself included) have asked some pretty trivial, almost stupid, questions at some time or another. 
-
Charles256
- DevNet Resident
- Posts: 1375
- Joined: Fri Sep 16, 2005 9:06 pm
Code: Select all
$original_number=99;
$number_to_subtract=2;
$resulting_number=$original_number-$number_to_subtract;
echo "$original_number minus $number_to_subtract equals $resulting_number";-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Coding genius?Everah wrote:Not everyone here is a coding genius. Heck, some don't even have a grasp on the logic. I'd agree that the OP probably didn't do a lick of searching for the answer before posting. But cut him some slack. Most of us around here (myself included) have asked some pretty trivial, almost stupid, questions at some time or another.
Any value minus another is such a basic skill...and the required operator and 2 essential operands...
I'm sorry, but IMHO thats so basic...it's frustrating...
While I agree...there is no such thing as a stupid question...this one was at the very least almost rhetorical...
The answer would be given in almost any article or book if he/she would have read past the books preface...
I only harp because it's screams "I'm overly anxious or really lazy" in which case...my opinion IMHO was needed
Cheers
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
I agree with you in every regard. The only thing I would add (not really to rebut you, just to note) is that eventhough someone knows the process to achieve something in one medium does not mean that they can do it in another. Say I know that the difference between two numbers is the greater of the two less the lesser of the two. I can do this in plain, simple written math. However, I don't know how to do it in some other language (say PHP, ASP, Cobol, Ruby, Python or anything else). So I ask. Like the original poster.
But I am totally in agreement with you. This is probably one of the easier things to find using google. If one would try...
EDIT: Sorry about this post coming in after the last one.
But I am totally in agreement with you. This is probably one of the easier things to find using google. If one would try...
EDIT: Sorry about this post coming in after the last one.
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Staying on topic and being productive: http://www.developer.com/lang/php/article.php/938511
Read it...it's good for you...like chicken soup when your sick
Read it...it's good for you...like chicken soup when your sick
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg