Hi,
I am trying to search for numbers in an array - "explodedArray" which has been "exploded from a text entry. The aim is to be able to allow the user to type something in like " 5 + 5 " or "5 plus 5" or even "5 plus 5 minus 10 + 4" etc...
The following code was a test to implement the "5 plus 5" scenario. Unfortunately, it doesn't work. I am just beginning with PHP and have looked through a lot of things and this is what I wrote.
If you could help me, show me another method or something along those lines, I would be grateful.
Thanks very much.
if (array_search("plus", $explodedArray))
{
$explodedArrayNumber = count($explodedArray);
while ($explodedArrayNumber > 0)
{
$explodedArrayNumber -= 1;
if (is_int($explodedArray[$explodedArrayNumber]))
{
$total += $explodedArray[$explodedArrayNumber];
echo "$total";
}
}
}
Sorry for the weird indenting - it looks very different ( a lot better) in Dreamweaver but really bad here.