i want to search the calcType array looking for the operator =. and if its found if the one before it was + - * or /. take the running total and iether add the last input to it, or * / -. it is not working though, am i getting the comparison between strings wrong or the array search? thanks
$_SESSION[‘result’] hasnt been set so is therefore empty, and $input also hasnt been set, so is equally empty.
Therefore you exit with with nothing
Sorry your explaination wasnt clear enough for me to decide what you wish to do once youve found the condition.
You say add as in + you cannot add a number to a character, do you mean append the $input to the character ‘=’ ? , ie if $input was ‘6’, you want to output ‘=6’. to append a string you use the ‘.’ operator, so your ‘+’ would need to be a ‘.’
sorry for being unclear. i am making a calculator that has a running total and can have an an ongoing string of calculations. i have set $input and $_SESSION[‘result’] above this code with - if(!$input){$input = 0;} and the same for result.
i basicly want the code to say, when i press the equals button, find the operator that was last used before 0 and do that to the number in the input.so the result is say 60 so far, then i put a number into the input with a * operator and press equals. so 60 * 2 = 120.