源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

php字符串按照单词进行反转的方法

  • 时间:2020-07-15 06:10 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:php字符串按照单词进行反转的方法
本文实例讲述了php字符串按照单词进行反转的方法。分享给大家供大家参考。具体分析如下: 下面的php代码可以将字符串按照单词进行反转输出,实际上市现将字符串按照空格分隔到数组,然后对数组进行反转输出
<?php
$s = "Reversing a string by word";
// break the string up into words
$words = explode(' ',$s);
// reverse the array of words
$words = array_reverse($words);
// rebuild the string
$s = implode(' ',$words);
print $s;
?>
输出结果如下: word by string a Reversing 希望本文所述对大家的php程序设计有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部