-
面试题是全英文的,但单词都比较熟悉算是好理解,而且有案例。所以,稍微细心一点是完全可以避免的,这里写下题目,以及解题过程。
-
题:
If you think the description is incomplete and affect the answers in any way, please make appropriate assumption and describe it in the answer· We are a PHP shop and prefer you answering in PHP. But you might answer in any other languages in case you are not familiar with it, we accept answers in C#, Java, Javascript, Python, Perl, C++, Ruby, etc.Problem StatementThe input is an English sentence as a string, we need a function - “function convert($input)” that can transform it as described below and return a new string.The sentence would contain only alphabet (a-z and A-Z) and space, each word would be separated by exactly one space. There would be no spaces before and after the sentence.Please return the string with each word spelled in reverse, however, the position of the capitalization of each letter should stay the same for each word.For example:Input: Many people spell MySQL incorrectlyOutput: Ynam elpoep lleps LqSYM yltcerrocni复制代码
- 解:
$string = 'Many people spell MySQL incorrectly';function myStrrev($string){ $paterrn = '/^([a-zA-Z]){1,100}((\s){1}([a-zA-Z]){1,100})*$/'; //假设一个单词最大范围1-100 if(preg_match($paterrn,$string)) { $data = explode(' ',$string); foreach($data as $key => $value){ $newValue = strtolower(strrev($value)); for($i=0;$i
- 不管是开发也还,还是做题也好。正确理解题目永远是最关键的,心里毒打自己一百遍!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!