By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,718 Members | 1,275 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,718 IT Pros & Developers. It's quick & easy.

Handle String-Variable as mathematical order

P: n/a
Hi there,

i just wondered if it is possible to handle a string variable as a
mathematical order.

If the variable contains i.e. "2*100" PHP should calculate it, so that i'm
able to assign the the result to another variable.
How can i realise this if it is possible
Thanks for the help,
Johannes
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"MatrixCrawler" <j.***********@t-online.de> wrote in message
news:cl*************@news.t-online.com...
Hi there,

i just wondered if it is possible to handle a string variable as a
mathematical order.

If the variable contains i.e. "2*100" PHP should calculate it, so that i'm
able to assign the the result to another variable.
How can i realise this if it is possible
Thanks for the help,
Johannes


Tested:

<?php
$math = "2*100";
eval("\$math2 = $math;");
print $math2;
?>
Jul 17 '05 #2

P: n/a
Thank you for the help!

Works perfectly for me!
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.