PHP interview questions and answers, php questions and answers. PHP interview questions and answers, php questions and answers 1. write a function to convert the string open_door to OpenDoor and make_by_id to MakeById. Functionstr _ 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 ′)));
$ 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"
";
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.
Example 1. write a function to convert the string "open_door" to "OpenDoor" and "make_by_id" to "MakeById ". Function str _...