I'm trying to code a function that will do some mathematical operations. Here's an example:
function test($number){
$result = 5 * $number[2];
echo $result;
}
So if I enter a number "12345", I want to multiply the number at index 2 with 5. So in this case, I should be multiplying 5*3 and get 15.
But I always get 0. I found the error why I'm always getting 0. It's because $number[2] isn't working. So how do I get a number at a certain index and then calculate with it?