Simple math question

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
User avatar
lenton
Forum Commoner
Posts: 49
Joined: Sun Jun 20, 2010 6:45 am

Simple math question

Post by lenton »

I have this code:

Code: Select all

$input = "3-1";
$output = $input;
How would I get $output to equal '2'?
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: Simple math question

Post by Apollo »

Code: Select all

eval("\$output = $input;");
User avatar
lenton
Forum Commoner
Posts: 49
Joined: Sun Jun 20, 2010 6:45 am

Re: Simple math question

Post by lenton »

Thanks for your help, I've got it working now :)
Post Reply