Solve--where to go to the net written question----is this a Chinese word?

Source: Internet
Author: User
Where to go online written Chinese word breaker program

Took part in the written test of where to go net
The main idea: Asp.php.jsp.javascript language is not limited to convert it into javascript.jsp.php.asp
This means that the user enters a string that contains a number of "." Separated characters), you write a program implemented with these "." For the separation, turn the original sentence upside down.


Reply to discussion (solution)

Looks like the conversion of the group, and then the reverse is possible.

The question is how to implement the "." To separate it? The conversion of a character between two points into an array cell. Great God Solution

Looks like the conversion of the group, and then the reverse is possible.
The question is how to implement the "." To separate it? The conversion of a character between two points into an array cell.

$s = ' asp.php.jsp.javascript '; Echo join ('. ', Array_reverse (Explode ('. ', $s)));
Javascript.jsp.php.asp

$s = ' asp.php.jsp.javascript '; Echo join ('. ', Array_reverse (Explode ('. ', $s)));
Javascript.jsp.php.asp
Moderator Big God thick line, it seems that my PHP has to learn! Sheida!

If you are not the kind of "repeated war" type, suggest or more practice for a period of time to go to the interview good, or you will always face failure to fight their confidence

That's the basics, right?

is expected to be implemented with non-system self-brought functions.

That's the basics, right?
Well, it was actually a struggle to write a function or something.

is expected to be implemented with non-system self-brought functions.
Well, that was the idea.

If you are not the kind of "repeated war" type, suggest or more practice for a period of time to go to the interview good, or you will always face failure to fight their confidence
NN Thank you!

Non-system comes with a function to achieve, do not array_reverse, you can write it.

function Reverse_str ($s) {$r =explode ('. ', $s); $c =count ($r); $i =0;foreach ($r as $k + $v) {if ($i < $c/2) {$r [$k]= $r [$ c-1-$i];//The first key value is equal to the last value $r[$c-$i]= $v;//The last key value equals the first value, and so on the interchange key value $i++;} Else{break;}} return join ('. ', $r);} Test $s= "1.2.3.4.5.6"; Echo reverse_str ($s);


Hope to help you.

Non-system comes with a function to achieve, do not array_reverse, you can write it.

function Reverse_str ($s) {$r =explode ('. ', $s); $c =count ($r); $i =0;foreach ($r as $k + $v) {if ($i < $c/2) {$r [$k]= $r [$ c-1-$i];//The first key value is equal to the last value $r[$c-$i]= $v;//The last key value equals the first value, and so on the interchange key value $i++;} Else{break;}} return join ('. ', $r);} Test $s= "1.2.3.4.5.6"; Echo reverse_str ($s);


Hope to help you.

Well, string processing is a very important part of web development. 3Q
  • 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.