How to update and retrieve a PHP variable without reloading webpage?

I am trying to create a trading bot in PHP, where the last price of the commodity is retrieved into a variable called $ last. Now, within the program, i want to set a condition such that, if $ last reaches a certain value, then a certain condition is executed, now here is the problem, I am locally running the PHP file on xampp, and $ last is updated only when page is reloaded, but i want it to be updated to value of $ last without me manually reloading page every time(because that`s what a bot is meant to do!). Is there any solution for this in PHP? Any help in this issue will be highly appreciated! Thanks in advance!