File "analyse_string01.php"

Full Path: /home/analogde/www/Design/fileman/Fusion/Table/analyse_string01.php
File size: 1.67 KB
MIME-type: text/x-php
Charset: utf-8

<?php

	$str = '8560841836';
	$len = strlen($str);

	for($i = 0; $i < $len; ++$i) 
    echo $str[$i]."</br>";


	//$pattern = '/^[0-9]+$/';
	
	// is_int
	// is_float

	echo "<br>";
	echo "<br>";
	echo "<br>";

	test_float(235);
	echo "<br>";
	test_float(23.5);
	echo "<br>";
	
	echo "<br>";
	echo "-----> " .gettype("357");
	echo "<br>";
	echo "-----> " .gettype(357);
	echo "<br>";
	echo "-----> " .gettype("3.57");
	echo "<br>";
	echo "-----> " .gettype(8.789);
	echo "<br>";	
	
	$type_val = convert_to_string(123);
	echo gettype($type_val);
	
	/*$test = is_float(23.5);
	
	if( $test == false)
	{
		echo "23.5 est-il un floattant ? " .$test;
	}
	else	
	
	$test = is_float(235);
	
	if( $test == false)
	{
		echo "lmkjkljkljkllk";
	}		
	echo "235 est-il un floattant ???? ? " .$test;
	*/
	echo "<br>";
	echo "<br>";
	
	
	echo substr_count("78.123.788","."); // compte les points  donc 2
	echo "<br>";
	echo substr_count("78123.788","."); //  idem donc 1
	echo "<br>";
	echo substr_count("78123788",".");  // idem doc 0
	echo "<br>";
	
	
	$str = '0.8560841836';
	
	if( $str[0] == "0" && $str[1] == "." )
	{
		echo " blabla ...";
	}		
	

	/*if(!preg_match('#[^0-9]#',$value))
	{
		echo "Value is numeric";
	}
	else
	{
		echo "Value not numeric";
	}*/

function convert_to_string($val)
{
	
	return strval($val);
}

/*function nombre_valide($val)
{

	substr_count("78.123.788","."); // compte les points  donc 2

	
}*/

function test_float($val)
{
	$test = is_float($val);
	
	if( $test == false)
	{
		echo $val ." n'est pas un floattant ?."; 
	}
	else
	{
		echo $val ." est un floattant ?"; 
	}		
	
}

?>