This holiday is very full. It should be said. If you have a guest, you are busy with yourself. Time passes quickly. Such a relaxed day is indeed fascinating. The last day of the holiday is the last day of tomorrow. I wanted to have a good sleep and sleep late. Unfortunately, God didn't give me this opportunity. A few nights off, they all go to bed late, and the next day they are always subject to early biological clock.
This holiday is very full. It should be said. If you have a guest, you are busy with yourself. Time passes quickly. Such a relaxed day is indeed fascinating. The last day of the holiday is the last day of tomorrow. I wanted to have a good sleep and sleep late. Unfortunately, God didn't give me this opportunity. A few nights off, they all go to bed late, and the next day they are always subject to early biological clock.
This holiday is very full. It should be said.
If you have a guest, you are busy with yourself. Time passes quickly.
Such a relaxed day is indeed fascinating.
The last day of the holiday is the last day of tomorrow.
I wanted to have a good sleep and sleep late. Unfortunately, God didn't give me this opportunity.
A few nights off, they all go to bed late. The next day, they are always woken up early by the biological clock...
From last night, I felt a bit cool. It seems that the autumn is coming soon.
You must pay attention to your health. Be careful when catching the cold.
Continue to cheer!
Share some code snippets.
In Bash, it is often used to obtain the script directory.
$(pwd)Later, more standardized
$(cd "$(dirname "$0")"; pwd)But since the recent Bash vulnerability, it is not available. Slightly changed
$(cd "$(dirname "${BASH_SOURCE[0]}")"You can continue to have fun again.
Run the pwd command to print name of current/working directory.
Strictly speaking, there is no meaning here. The output directory is the directory where the script is stored. But it does have this function.
In PHP, using array_intersect to calculate the intersection of two arrays is faster than using array_diff to calculate the union of the two arrays.
If the number of difference sets between array $ a and array $ B is required, use
count($a) – count(array_intersect($a, $b));Instead of using
count(array_diff($a, $b));The front is faster than the latter, and more obvious in the large array.
In some languages, functions can return multiple values, such
function () {
return $a, $b, $c;
}PHP does not support the function returned like this. How can this problem be achieved:
function abc() {
return array($a, $b, $c);
}
list($x, $y, $z) = abc();In this way, the returned values are more concise. In an instant, the processing speed is increased.
The complete code is
function abc() {
$a = array();
$a[] = 1;
$a[] = 2;
$b = 11;
$c = 12;
return array($a, $b, $c);
}
list($x, $y, $z) = abc();
var_dump($x, $y, $z);Still cool...
Automatically add st \ nd \ rd to the number:
function make_ranked($rank) {
$last = substr( $rank, -1 );
$seclast = substr( $rank, -2, -1 );
if( $last > 3 || $last == 0 ) $ext = 'th';
else if( $last == 3 ) $ext = 'rd';
else if( $last == 2 ) $ext = 'nd';
else $ext = 'st';
if( $last == 1 && $seclast == 1) $ext = 'th';
if( $last == 2 && $seclast == 1) $ext = 'th';
if( $last == 3 && $seclast == 1) $ext = 'th';
return $rank.$ext;
}It's just that I got something that I can pretend to be forced to use.
Well, there is also an interface for PHP to get short urls:
function getTinyUrl($url) {
return file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
}Very convenient!
The above are purely words.
Reprinted please note