There may be a difference, but it is going to be negligible for 99.9% of real-world cases. In either case, PHP will call your function/method only once. What happens internally when you use foreach is that PHP evaluates the iteratee (the part before the as) once, stores the result, and then loops over it, putting the current element into the local variable given after the as. If you write the iteratee to a local variable yourself, you are practically just duplicating PHP's effort, so the first approach may carry an extra overhead, but it's not going to be enough to worry about. I'd optimize for readability instead: if the function call is short and self-describing, inline it; if it's complex or obscure, store it in a descriptive variable instead.
Note that the situation is different with typical for and while loops, which is probably where you got this notion from. For example, in the following code:
for ($number = 0; $number < $this->getNumberOfItems(); ++$number) {
// do stuff...
}
...the getNumberOfItems() method gets called on every iteration. In this situation, it makes sense to precalculate it and store it in a local variable.
$valuesand the foreach loop will reference the same dataset. The only thing to consider is when the variable can be garbage collected, which is earlier in the first example (at the end of the loop) than in the second (at the end of the function/file or whenunset()is called).