This article shares an article about the PHP interview pen question one, the need for friends can refer to
* Please implement a function, enter a text, parse the text into an array, the key of each line element of the array is specified by the input parameter.
Functional Prototypes: Function Explodelines ($text, $columnNames)
For example, enter:
| The code is as follows |
Copy Code |
$text = " Apple,20,red Pear,10,yellow "; $columnNames = Array (' Fruit ', ' number ', ' Color ') function returns: Array Array (' Fruit ' = ' Apple ', ' number ' = ' + ', ' Color ' = ' red '), Array (' Fruit ' = ' = ' Pear ', ' number ' = ' ', ' ' "'" ' "') ', ' Color ' = ' yellow '), ) */ |
Instance method
| The code is as follows |
Copy Code |
$arr =array ();
$file = file_get_contents ("file.txt");
$file and $arr = Explode ("rn", $file);
$columnNames = Array (' Fruit ', ' number ', ' Color ');
$rs = Explodelines ($arr, $columnNames);
Print_r ($RS);
function Explodelines ($text, $columnNames) { $array = Array (); foreach ($text as $key = = $val) { if ($val! = "") { $array [] = Array_combine ($columnNames, Explode (",", $val)); } } return $array;
} |
Question Two
Design a system (database structure and logical flow) to meet the following requirements:
1, the user can obtain the above types of gold coins correctly
2, users can always know how many coins they can spend, how many coins are frozen
3. The frozen gold coins can be consumed after the freezing period.
4, the user can consume their own available gold coins
You only need to design a workable scenario that describes the database structure and logical algorithms:
1. Issue a gold coin and issue B gold coins
2, to obtain the current number of available gold coins, consumption of available gold coins, to obtain the current frozen coins frozen, frozen gold coins to usable gold, recycling frozen gold coins
Category: Face questions
$arr =array ();
$file = file_get_contents ("file.txt");
$file and $arr = Explode ("rn", $file);
$columnNames = Array (' Fruit ', ' number ', ' Color ');
$rs = Explodelines ($arr, $columnNames);
Print_r ($RS);
function Explodelines ($text, $columnNames) {
$array = Array ();
foreach ($text as $key = = $val) {
if ($val! = "") {
$array [] = Array_combine ($columnNames, Explode (",", $val));
}
}
return $array;
}
http://www.bkjia.com/PHPjc/629183.html www.bkjia.com true http://www.bkjia.com/PHPjc/629183.html techarticle This article shares an article about the PHP interview pen question one, the need for friends can refer to * Please implement a function, enter a text, the text into an array, the array of each line ...