1. Write a function to put 1,2,3,4,5,6 randomly into an array, 3 cannot be in the third position, 5 and 6 cannot be next to each other.
function Sort_test ($array) { while (true) { shuffle ($array); $temp = Array_flip ($array); if ($array [2]! = 3 && 1! = ABS ($temp [5]-$temp [6]) { return $array; }} } $array = Array (1,2,3,4,5,6);p Rint_r (Sort_test ($array));
2, write a function to implement the string $str= "Asdfasflasdfopafdsa", the first occurrence of the letter.
function Get_target_letter ($str) { $i = 0; $array = Array (); while (Isset ($str [$i])) { $array [$STR [$i]] = isset ($array [$STR [$i]])? $array [$str [$i]] + 1:1; $i + +; } foreach ($array as $key = + $val) { if ($val = = 1) { return $key; } } return false;} echo get_target_letter (' ASDFASTFLASDFOPAFDSA ');
3. There are two tables:
CREATE TABLE Products ( product_id INT UNSIGNED not NULL PRIMARY KEY auto_increment, product_name VARCHAR (+) not NULL); CREATE TABLE orders ( product_id int UNSIGNED not NULL, create_at int UNSIGNED NOT NULL, num INT UNSIGNED not NULL);
Write an SQL statement that queries the product name, the total number of sales, and the total number of sales in the T1-t2 period from highest to lowest.
My approach:
Select products.product_name, number.numfrom ((SELECT product_id, sum (num) as num from orders WHERE orders.create_at between {$t 1} and {$t 2} GROUP by product_id) as number) INNER JOIN products on products.product_id = Number.product_idorder by Number.num DESC;
These three questions the impression is more profound other not quite remembers, the answer is writes according to my own practice, the wrong place please correct me
The above on the introduction of today to gather the United States several face questions, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.