Home > php教程 > php手册 > php面试笔试题一

php面试笔试题一

WBOY
Release: 2016-06-13 10:14:33
Original
1441 people have browsed it

本文章分享一篇关于php面试笔试题一,有需要的朋友可以参考一下

* 请实现一个函数,输入一段文本,把文本解析到一个数组中,数组每行元素的key通过输入参数指定。

函数原型:function ExplodeLines($text, $columnNames)

例如,输入:

 代码如下 复制代码

$text = "
Apple,20,red
Pear,10,yellow
";
$columnNames = array('Fruit', 'Number', 'Color')

函数返回:
array(
array('Fruit'=>'Apple', 'Number'=>'20', 'Color'=>'red'),
array('Fruit'=>'Pear', 'Number'=>'10', 'Color'=>'yellow'),
)
*/

实例方法

 代码如下 复制代码
$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;
 
}

题二

请设计一个系统(数据库结构和逻辑流程),满足以下要求:

1、用户可以正确的获得上述类型金币

2、用户随时可以知道自己有多少金币可以消费,有多少金币被冻结

3、被冻结的金币在冻结期后成为可以消费的金币

4、用户可以消费自己的可用的金币

只需要设计一种可行方案,描述数据库结构和逻辑算法:

1、发放A金币、发放B金币

2、获取当前有多少可用金币、消费可用金币、获取当前有冻结金币的冻结情况、冻结金币转为可用金币、回收冻结金币

 

 

分类: 面试题

 
$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;
 
}

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template