PHP Interview Questions and Answers, php Questions and answers
1. Write a function to implement the following functions:
Convert the string "open_door" to "OpenDoor" and "make_by_id" to "MakeById ".
Function str_change ($ str ){
$ Str = str_replace ("_", "", $ str );
$ Str = ucwords ($ str );
$ Str = str_replace ("", "", $ str );
Return $ str ;}
2. Write a program to convert the following array $ arr1 into an array $ arr2:
$ Arr1 = array (
'0' => array ('fid' => 1, 'tid' => 1, 'name' => 'name1 '),
'1' => array ('fid' => 1, 'ti' => 2, 'name' => 'name2 '),
'2' => array ('fid' => 1, 'tid' => 5, 'name' => 'name3 '),
'3' => array ('fid' => 1, 'tid' => 7, 'name' => 'name4 '),
'4' => array ('fid' => 3, 'tid' => 9, 'name' => 'name5 ')
);
$ Arr2 = array (
'0' => array (
'0' => array ('tid' => 1, 'name' => 'name1 '),
'1' => array ('tid' => 2, 'name' => 'name2 '),
'2' => array ('tid' => 5, 'name' => 'name3 '),
'3' => array ('tid' => 7, 'name' => 'name4 ')),
'1' => array (
'0' => array ('tid' => 9, 'name' => 'name5 ′)));
<? Php
$ Arr1 = array (
'0' => array ('fid' => 1, 'tid' =>, 'name' => 'name1 '),
'1' => array ('fid' => 1, 'tid' => 2, 'name' => 'name2 '),
'2' => array ('fid' => 1, 'tid' => 5, 'name' => 'name3 '),
'3' => array ('fid' => 1, 'tid' => 7, 'name' => 'name4 '),
'4' => array ('fid' => 3, 'tid' => 9, 'name' => 'name5 ')
);
Function changeArrayStyle ($ arr ){
Foreach ($ arr as $ key => $ value ){
$ Result [$ value [\ fid \] [] = $ value;
}
Return array_values ($ result );
}
$ Arr2 = changeArrayStyle ($ arr1 );
Echo "<pre> ";
Var_dump ($ arr2 );
?>
3. Briefly describe the database design paradigm and application.
Generally, the 3rd paradigm is enough to optimize the table structure. This can avoid the complexity of applications and the low system efficiency caused by too large SQL statements.
ANSWER:
First paradigm: if every attribute of the relational model R cannot be decomposed, then it belongs to the first paradigm.
Second paradigm: If R belongs to the first paradigm, and all non-Code attributes depend entirely on the Code attributes, the second paradigm is used.
Third paradigm: If R belongs to the second paradigm, and none of all non-Code attributes depend on candidate codes, then it belongs to the third paradigm.