📜 ⬆️ ⬇️

Check the presence of numbers in the string

The other day I ran into an interesting task and decided to share it with you.
The task is as follows: it is necessary to check the presence of numbers in the string. The main condition is not to use regular expressions.

A language, in principle, any, is interesting exactly the approach to the solution. Well, and, of course, it is desirable, the optimized decision.

Here is my
function check_for_number($str) { $lenght = strlen($str); for($i=0;$i<$lenght;) { if (is_numeric($str[$i++])) { return true; } } return false; } 

')

Source: https://habr.com/ru/post/113544/


All Articles