Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Post Timeline

added 524 characters in body
Source Link
user4308987
user4308987

I did at the end of the function to check for numeric data.

return is_numeric($text)&&!(is_int(strpos($text,".",0)));

It will first check if it is numeric then check if there is no decimal in the string by checking if it found a position. If it did the returned position is an int so is_int() will catch it.

(strpos($text,".",0)==FALSE) would also work based on the strpos manual but sometimes the function seems to send nothing at all back like

echo (strpos($text,".",0));

could be nothing and the ==FALSE is needed.

I did

return is_numeric($text)&&!(is_int(strpos($text,".",0)));

I did at the end of the function to check for numeric data.

return is_numeric($text)&&!(is_int(strpos($text,".",0)));

It will first check if it is numeric then check if there is no decimal in the string by checking if it found a position. If it did the returned position is an int so is_int() will catch it.

(strpos($text,".",0)==FALSE) would also work based on the strpos manual but sometimes the function seems to send nothing at all back like

echo (strpos($text,".",0));

could be nothing and the ==FALSE is needed.

Post Undeleted by Community Bot
Post Deleted by Community Bot
Source Link
user4308987
user4308987

I did

return is_numeric($text)&&!(is_int(strpos($text,".",0)));
lang-php

AltStyle によって変換されたページ (->オリジナル) /