<?php
$list=array(1,2,3,4,5,6);
$line=0;
foreach($list as $value){
$line+=1;
if($line>4){
$line=1;
}
echo "$value :$line<br>";
}
?>
1 :1
2 :2
3 :3
4 :4
5 :1
6 :2
lunes, 26 de marzo de 2018
lunes, 19 de marzo de 2018
PHP Date Practice
Creating a date and adding a time interval
<?php
$date = new DateTime();
echo $date->format('Y-m-d H:i:sP') . "<br>";
$date->add(new DateInterval('P30D')); //adding 30 days
echo $date->format('Y-m-d H:i:sP') . "\n";
Creating a date using computer time and also specifying time zone
<?php// Specified date/time in your computer's time zone.
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:sP') . "\n";
// Specified date/time in the specified time zone.
$date = new DateTime('2000-01-01', new DateTimeZone('Pacific/Nauru'));
echo $date->format('Y-m-d H:i:sP') . "\n";
// Current date/time in your computer's time zone.
$date = new DateTime();
echo $date->format('Y-m-d H:i:sP') . "\n";
// Current date/time in the specified time zone.
$date = new DateTime(null, new DateTimeZone('Pacific/Nauru'));
echo $date->format('Y-m-d H:i:sP') . "\n";
// Using a UNIX timestamp. Notice the result is in the UTC time zone.
$date = new DateTime('@946684800');
echo $date->format('Y-m-d H:i:sP') . "\n";
<?php
$date = new DateTime();
echo $date->format('Y-m-d H:i:sP') . "<br>";
$date->add(new DateInterval('P30D')); //adding 30 days
echo $date->format('Y-m-d H:i:sP') . "\n";
Object oriented style
<?php
$date = new DateTime('2000-01-01');
$date->add(new DateInterval('P10D'));
echo $date->format('Y-m-d') . "\n";?>
Procedural style
<?php
$date = date_create('2000-01-01');
date_add($date, date_interval_create_from_date_string('10 days'));
echo date_format($date, 'Y-m-d');?>
http://php.net/manual/en/datetime.add.php
Formats supported :http://php.net/manual/en/datetime.formats.relative.php
<?php// Specified date/time in your computer's time zone.
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:sP') . "\n";
// Specified date/time in the specified time zone.
$date = new DateTime('2000-01-01', new DateTimeZone('Pacific/Nauru'));
echo $date->format('Y-m-d H:i:sP') . "\n";
// Current date/time in your computer's time zone.
$date = new DateTime();
echo $date->format('Y-m-d H:i:sP') . "\n";
// Current date/time in the specified time zone.
$date = new DateTime(null, new DateTimeZone('Pacific/Nauru'));
echo $date->format('Y-m-d H:i:sP') . "\n";
// Using a UNIX timestamp. Notice the result is in the UTC time zone.
$date = new DateTime('@946684800');
echo $date->format('Y-m-d H:i:sP') . "\n";
domingo, 18 de marzo de 2018
printing date and unixtime
$date = date_create(); //create date object based on current date
echo date_format($date, 'Y-m-d H:i:s'); // format and print date
echo "<br>";
echo $date->getTimestamp(); // print the unix time of current date
echo date_format($date, 'Y-m-d H:i:s'); // format and print date
echo "<br>";
echo $date->getTimestamp(); // print the unix time of current date
sábado, 10 de marzo de 2018
IBM tts API
https://michaelheap.com/speech-to-text-with-ibm-watson-and-php/
domingo, 25 de febrero de 2018
couting first array value and remove it
<?php
$queue=array(1,2,3,4,5);
foreach($queue as $value){
$post=current($queue);
echo current($queue);
array_shift($queue);
echo "<br>";
}
?>
will be used for a custom asterisk queue
$queue=array(1,2,3,4,5);
foreach($queue as $value){
$post=current($queue);
echo current($queue);
array_shift($queue);
echo "<br>";
}
?>
will be used for a custom asterisk queue
sábado, 17 de febrero de 2018
array callback fuctions
<?php
//////////apply this fuction to all values of input array
function cube($n)
{
return($n * $n * $n);
}
$a = array(1, 2, 3, 4, 5);
$b = array_map("cube", $a);
print_r($b);
code 2
//////////////////////////// return an array with all values of input array > 2
function fuv($n)
{
if($n>2) {
return true;
}
}
$c=array_filter($a,"fuv");
print_r($c);
//////////apply this fuction to all values of input array
function cube($n)
{
return($n * $n * $n);
}
$a = array(1, 2, 3, 4, 5);
$b = array_map("cube", $a);
print_r($b);
code 2
//////////////////////////// return an array with all values of input array > 2
function fuv($n)
{
if($n>2) {
return true;
}
}
$c=array_filter($a,"fuv");
print_r($c);
lunes, 5 de febrero de 2018
google vision image api
curl -X POST -H "Content-Type: application/json" -d '{"requests": [{ "features": [ {"type": "LABEL_DETECTION"}], "image": {"source": { "imageUri": "https://storage.googleapis.com/ambiorixg12/image2.jpg"}}}]}' https://vision.googleapis.com/v1/images:annotate?key=mykey
https://cloud.google.com/vision/docs/using-curl
https://cloud.google.com/vision/docs/auth#using_an_api_key
https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#ImageSource
https://cloud.google.com/vision/docs/using-curl
https://cloud.google.com/vision/docs/auth#using_an_api_key
https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#ImageSource
Suscribirse a:
Entradas (Atom)