PHP Interview Questions and Answers, php Questions and answers

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.