Php Function Use Outer Variable Speed