There is an XML document, it is a parsing of field values, and then you need to know the type of value written in a string variable. To determine the type of value in a variable, wrote such a function.
public function getTypeValue($var) { if (is_numeric($var)) { if (is_int($var)) { return 'int'; }elseif (is_integer($var)){ return 'integer'; }elseif (is_long($var)){ return 'long'; }elseif (is_float($var)){ return 'float'; }elseif (is_double($var)){ return 'double'; }else{ return "len: " . strlen($var); } }else{ return 'string'; } } Whatever one may say, where there are strings, it returns string , where there are numbers (014982, 2, 3, 3.1.3, etc.) the function returns information on the length of the string but not the type. The else block for numbers made to check whether there are any extraneous characters in the string that would interfere. The results show that there is nothing outside there. If we take an ordinary array and fill it with data, the function works correctly, that is, it defines both strings and numbers of different types. How to overcome the situation?
XML processing code:
public function parse() { $fullpath = PATH_XMLFOLDER . "/linecheck.xml"; $xml = simplexml_load_file($fullpath); $fields = $xml->xpath('//fields/*'); foreach ($fields as $field) { $fieldName = (string)$field->getName(); $value = (string)$field; $typeValue = $this->getTypeValue($value); SVTools::sv_debug($value,0); SVTools::sv_debug($typeValue,0); } }