This question already has answers here:
calculate math expression from a string using eval
(10 answers)
Closed 4 years ago.
If i've a string like this
((((((4,50*0,86)*52500*1,0016)+3800)/52500)*2,2046)*1,05)
how can i do the operation for obtaning the total result?
Thank You
Maybe your question is a possible duplicate from calculate-math-expression-from-a-string-using-eval
However
if you need to store this in a variable you can do
$string='((((((4,50*0,86)*52500*1,0016)+3800)/52500)*2,2046)*1,05)';
$response=eval('return '.str_replace(',','.',$string.';'));
print($response);
the output is:
9.14027512736
Related
This question already has answers here:
PHP & Case Sensitivity [duplicate]
(3 answers)
Closed 1 year ago.
Is there a difference ?
I don't get it.
Or maybe a string is a class and
String is a reference to the System.string?
like in c#
string in php is not an object, which mean, you can't use method like equals or other that can be use in java.
string in php is a type as well as float, int ...
This question already has answers here:
Getting a number when it has certain prefix from a block of text in PHP
(3 answers)
Zero-pad digits in string
(5 answers)
Closed 1 year ago.
I am trying to add the int with strings in PHP but I could get a helpful answer on StackOverflow and other website communities.
I want the code separate the ALPHABETS and NUMBER and then add the value in NUMBER and again JOIN the ALPHABETS AND ADDED NUMBER together.
How I achieve this, Please help.
Example:
$mynumber = 'SBI0001';
$addValue = '1';
It will be 'SBI0002' in PHP.
This question already has answers here:
Get string between two strings
(6 answers)
Closed 6 years ago.
I'm trying to get the string between two specific matches, for example two hashtags.
What I would like to achieve:
input: some text in front ##hi there## some text behind
output: hi there
With /%%(.*)%%/, ##hi there## is returned.
Thanks in advance
You need a look ahead and look behind.
(?<=##).*(?=##)
This will match hi there
https://regex101.com/r/qUR4NR/1
This question already has an answer here:
How to extract and access data from JSON with PHP?
(1 answer)
Closed 6 years ago.
I have multidimensional array string stored in PHP variable and I want to extract the keys and its values. Below is the given string which need to be split.
[{"cutoffTime":"1","refundInPercentage":"50"},
{"cutoffTime":"3","refundInPercentage":"70"},
{"cutoffTime":"6","refundInPercentage":"90"}
]
How can I extract this?
Try this to have your work done
json_decode($string)
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
how to reformat a number with commas
Formatting numbers with thousands separator Smarty PHP
Format a number with grouped thousands
For example the following code:-
{php}echo $youtube->_views;{/php}
returns 2556789 and I want it formatted like this; 2,556,789
This topic says how to do it:
{$myvar|number_format:2:".":","}