Convert string Open_door to Opendoor, convert ABC_BCD_CDE to ABCBCDCDE

Source: Internet
Author: User
Convert string Open_door to Opendoor, convert ABC_BCD_CDE to ABCBCDCDE
    1. "HTML code"
    2. Convert string Open_door to Opendoor, convert ABC_BCD_CDE to ABCBCDCDE
Copy Code
    1. "PHP Code"/* Converts the string Open_door to Opendoor, converting ABC_BCD_CDE to abcbcdcde*/
    2. if ($_post[sub]== "Convert") {
    3. $string =$_post[string];
    4. if (Strstr ($string, "_"))
    5. {
    6. $arr =explode ("_", $string);
    7. Print_r ($arr);
    8. for ($i =0; $i<>
    9. {
    10. $arr [$i]=ucfirst ($arr [$i]);
    11. }
    12. $str =implode ("", $arr);
    13. Echo $str;
    14. }
    15. Else
    16. {
    17. $array =str_split ($string);
    18. for ($i =0; $i<>
    19. {
    20. $str =ucfirst ($array [$i]);
    21. if ($str = = $array [$i])
    22. {
    23. $array [$i]= "_". Strtolower ($arrar [$i]);
    24. }
    25. }
    26. $str 1=implode ("", $array);
    27. echo $str 1;
    28. }
    29. }
    30. ?>
Copy Code
  • 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.