inside a variable have multiple variables from database
//$row[formula] fetching from database and the store value is: ($basic - $advance)
$basic=100;
$advance=75;
echo $result= $row[formula];
// my output comes like this "($basic + $advance)"
and i want it come like this (100 - 75)
please help
I am not entirely sure what you mean as you are not displaying all of your code and don't explain what $row[formula] does or how it is used.
To echo the variables:
PHP Code:
echo '(' . $basic . ' - ' . $advanced . ')' ;
$basic=100;
$advance=75;
$row[formula]= ($basic - $advance) // this comes from database
when i echo "($basic - $advance)"; //my output comes (100 - 75)
but i echo "$row[formula]"; // then my output comes ($basic - $advance)
and i want when i echo $row[formula] my result will come=> (100 - 75);
Make sure you are showing us the exact code, as each of these will give you different results (note the difference in how the expressions are quoted):
PHP Code:
$foo = 8 ;
$bar = 9 ;
echo ( $foo - $bar ); // -1
echo '($foo - $bar)' ; // ($foo - $bar)
echo "( $foo - $bar )" ; // (8 - 9)
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in
Nation
eBookworm.us
$foo = 8;
$bar = 9;
thanks for reply
but this one is store in a variable -> ($foo - $bar);
example $a=($foo - $bar);
now when i echo $a my result is coming ($foo - $bar)
but i want when i echo $a it will show like (9 - 8);
note ($foo - $bar); is store in a variable // a=($foo - $bar);
NogDog has just given you the answer to this! So to use in your case you need to use the version
PHP Code:
echo "( $basic - $advance )" ; // (100 - 75)
PHP Code:
$basic = 500 ; $fetch [ amount ]= "( $basic * 10 / 100)" ; $fetch [ advance ]= "( $basic * 10 / 100) + ( $advance * 5 / 100) " ; $advance = str_replace ( '$basic' , $basic , $fetch [ 'amount' ]); $advance = calculate_string ( $advance ); // and is 50 echo $x = str_replace ( '$advance' , $advance , $fetch [ 'advance' ]); // echo result (500 * 10 / 100) + ( * 5 / 100)
$advance is missing
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks