This article shares a php interview question 1. if you need it, you can refer to the following to implement a function, input a piece of text, and parse the text into an array, the Keys of each element in the array are specified by input parameters.
This article shares a php interview question 1. if you need it, please refer to it.
* Implement a function. input a piece of text and parse the text into an array. the key of each element in the array line is specified by the input parameter.
Function prototype: function ExplodeLines ($ text, $ columnNames)
The instance code is as follows:
- $ Text ="
- Apple, 20, red
- Pear, 10, yellow
- ";
- $ ColumnNames = array ('fruit', 'number', 'color ')
Function return:
- Array (
- Array ('fruit' => 'apple', 'number' => '20', 'color' => 'red '),
- Array ('fruit' => 'pear ', 'number' => '10', 'color' => 'yellow '),
- )
- */
The instance code is as follows:
- $ 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;
- }
Design a system (database structure and logical process) to meet the following requirements:
1. the user can correctly obtain the above-mentioned gold coins
2. Users can know at any time how much gold coins they have can be consumed and how much gold coins are frozen.
3. Frozen Gold coins can be consumed after the freeze period
4. Users can purchase their own available gold coins.
You only need to design a feasible solution to describe the database structure and logic algorithm:
1. issue A gold coin and B gold coin
2. obtain the currently available gold coins, consume available gold coins, obtain frozen gold coins, convert frozen gold coins to available gold coins, and recycle frozen gold coins.
Category: interview 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;
- }