Php user-defined function recursively replaces the content in the array

Source: Internet
Author: User
Php user-defined function recursively replaces the content in the array

  1. /**

  2. Desc: recursively replaces array content
  3. Link: bbs.it-home.org
  4. Date: 2013/2/22
  5. */
  6. Function arrContentReplact ($ array)
  7. {
  8. If (is_array ($ array ))
  9. {
  10. Foreach ($ array as $ k => $ v)
  11. {
  12. $ Array [$ k] = arrContentReplact ($ array [$ k]);
  13. }
  14. } Else
  15. {
  16. $ Array = str_replace (
  17. Array ('<', '> '),
  18. Array ('{','}'),
  19. $ Array
  20. );
  21. }
  22. Return $ array;
  23. }

  24. // Call example

  25. $ Arr = array ("<jbxue1>", "<jb2xue>", array (" ", Array (" ")," <Jb33xue> "," <jbxue44> "," <44 jbxue> ");
  26. $ Arr3 = arrContentReplact ($ arr );
  27. Echo"
    ";
  28. print_r($arr3);
  29. echo "
  30. ";
  31. ?>

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.