I've building an app relating to a trading card game. I've got the casting cost of each card input into a string, i.e. 2BB
I want to calculate the total cost of the card. In this case, it would be 4. 2 + B + B.
The problem I'm having is I'm parsing out the string character by character, and checking it's type. When I pull the 2 out, it treats it like a string.
I'm using:
$length = strlen($Casting_Cost);
for ($i=0;$i<$length;$i++) {
$char = substr("$Casting_Cost", $i, 1);
if (is_string($char)) {
echo ("char is a string...");
}
else if (is_int($char)) {
echo ("char is a int...");
}
}
It's never hitting the is_int part of the if statememt.
How can I get the 2 to be treated like an integer?
Thanks,
-J