Pmiguelfpereira
12/18/2017 - 4:44 PM

Teste

<?php
	date_default_timezone_set('Europe/Lisbon');//or change to whatever timezone you want
	echo date('Y-m-d', strtotime("-30 days"));
	echo "<br>";
	echo date('Y-m-d');
	echo "<br>";	
	echo intval(0.6);
	echo "<br>";
	echo intval(1.6);
	echo "<br>";
	echo intval(2.6);
	$arraytest = array();
	$arraynum = 55;
	for($i=0;$i<$arraynum;$i++){
		$arraytest[] = array("teste" => $i+1);
	}
	$vz = ($arraynum/20);
	$vz = intval($vz) + 1;
	echo $vz;
	
	for($i=0;$i<$vz;$i++){		
		print "<pre>" . print_r($arraytest,1) . "</pre>";
		echo "<br>";
		count(count($arraytest));
		if(count($arraytest) > 20){
			echo "Maximo 20";
			echo "<br>";
			$arraytest = array_slice($arraytest, 20);
		}
		else{
			echo "Count do array";
			echo "<br>";
			$countarry = count($arraytest);
		}
	}
	
	//Encryp test
	function encrypt_decrypt($action, $string) {
	    $output = false;
	    $encrypt_method = "AES-256-CBC";
	    $secret_key = 'Qe9Lm6AADQNxLqQH57QtJjhn';
	    $secret_iv = 'TSNvkSGFLKVqnfAEAvwkr5Amk';
	    // hash
	    $key = hash('sha256', $secret_key);
    
	    // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning
	    $iv = substr(hash('sha256', $secret_iv), 0, 16);
	    if ( $action == 'encrypt' ) {
	        $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
	        $output = base64_encode($output);
	    } else if( $action == 'decrypt' ) {
	        $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
	    }
	    return $output;
	}
	
	$plain_txt = "1%7s66JB1*eh";
	echo "Plain Text =" .$plain_txt. "";
	echo "<br>";
	$encrypted_txt = encrypt_decrypt('encrypt', $plain_txt);
	echo "Encrypted Text = " .$encrypted_txt. "";
	echo "<br>";
	$decrypted_txt = encrypt_decrypt('decrypt', $encrypted_txt);
	echo "Decrypted Text =" .$decrypted_txt. "";
	echo "<br>";
	if ( $plain_txt === $decrypted_txt ) echo "SUCCESS";
	else echo "FAILED";
?>