Change a number -1

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Change a number -1

Post by ianhull »

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.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Code: Select all

$myVar = 99;
$myVar--;
echo $myVar;
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Aren't questions like that illegal? :P

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 :P

Cheers :)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

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. :wink:
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Ok so we learned how to subtract one. What if we wanted to subtract 2 :wink:
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

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";
now that was fun :-D
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

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. :wink:
Coding genius? :?

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 :P

Cheers :)
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Stay on topic... :?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

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.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

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 ;)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Aghhh....

Despite you having 85 posts under your name...IMHO you should really know better...

I apologize for biting like I did...

I genuinely feel like a dork now :P

Cheers :)
Post Reply