多次explode切割并组合,应该怎么做呢

php中文网
发布: 2016-06-23 13:41:53
原创
1505人浏览过

$a='youku$$$tudou$$$down'
$b='第一集$abcd
第一集$abcd
第二集$abcd
第三集$abcd
第四集$abcd
第五集$abcd$$$第一集$abcd
第一集$abcd
第二集$abcd
第三集$abcd
第四集$abcd
第五集$abcd$$$第一集$abcd
第一集$abcd
第二集$abcd
第三集$abcd
第四集$abcd
第五集$abcd'



都是$$$分割对应
最后$或者换行分割
最后需要得到
  • youku

  • 第一集
    第二集
    第三集
    第四集
    第五集

  • tudou

  • 第一集
    第二集
    第三集
    第四集
    第五集

  • down

  • 第一集
    第二集
    第三集
    第四集
    第五集

    AppMall应用商店
    AppMall应用商店

    AI应用商店,提供即时交付、按需付费的人工智能应用服务

    AppMall应用商店 56
    查看详情 AppMall应用商店

    回复讨论(解决方案)

    $a = 'youku$$$tudou$$$down';$b='第一集$abcd第一集$abcd第二集$abcd第三集$abcd第四集$abcd第五集$abcd$$$第一集$abcd第一集$abcd第二集$abcd第三集$abcd第四集$abcd第五集$abcd$$$第一集$abcd第一集$abcd第二集$abcd第三集$abcd第四集$abcd第五集$abcd';$a = explode('$$$', $a);$b = explode('$$$', $b);foreach($a as $i=>$r) {  echo "<li>$r</li>\n";  foreach(explode("\n", $b[$i]) as $v) {    $t = explode('$', trim($v));    echo "<a href='$t[1]' target='_top'>$t[0]</a>\n";  }}
    登录后复制
    <li>youku</li><a href='abcd' target='_top'>第一集</a><a href='abcd' target='_top'>第一集</a><a href='abcd' target='_top'>第二集</a><a href='abcd' target='_top'>第三集</a><a href='abcd' target='_top'>第四集</a><a href='abcd' target='_top'>第五集</a><li>tudou</li><a href='abcd' target='_top'>第一集</a><a href='abcd' target='_top'>第一集</a><a href='abcd' target='_top'>第二集</a><a href='abcd' target='_top'>第三集</a><a href='abcd' target='_top'>第四集</a><a href='abcd' target='_top'>第五集</a><li>down</li><a href='abcd' target='_top'>第一集</a><a href='abcd' target='_top'>第一集</a><a href='abcd' target='_top'>第二集</a><a href='abcd' target='_top'>第三集</a><a href='abcd' target='_top'>第四集</a><a href='abcd' target='_top'>第五集</a>
    登录后复制

    超链接输出错误了

    $a = 'youku$$$tudou$$$down';$b='第一集$abcd第一集$abcd第二集$abcd第三集$abcd第四集$abcd第五集$abcd$$$第一集$abcd第一集$abcd第二集$abcd第三集$abcd第四集$abcd第五集$abcd$$$第一集$abcd第一集$abcd第二集$abcd第三集$abcd第四集$abcd第五集$abcd';$a = explode('$$$', $a);$b = explode('$$$', $b);foreach($a as $i=>$r) {  echo "<li>$r</li>\n";  foreach(explode("\n", $b[$i]) as $v) {    $t = explode('$', trim($v));    echo "<a href='$t[1]' target='_top'>$t[0]</a>\n";  }}
    登录后复制
    <li>youku</li><a href='abcd' target='_top'>第一集</a><a href='abcd' target='_top'>第一集</a><a href='abcd' target='_top'>第二集</a><a href='abcd' target='_top'>第三集</a><a href='abcd' target='_top'>第四集</a><a href='abcd' target='_top'>第五集</a><li>tudou</li><a href='abcd' target='_top'>第一集</a><a href='abcd' target='_top'>第一集</a><a href='abcd' target='_top'>第二集</a><a href='abcd' target='_top'>第三集</a><a href='abcd' target='_top'>第四集</a><a href='abcd' target='_top'>第五集</a><li>down</li><a href='abcd' target='_top'>第一集</a><a href='abcd' target='_top'>第一集</a><a href='abcd' target='_top'>第二集</a><a href='abcd' target='_top'>第三集</a><a href='abcd' target='_top'>第四集</a><a href='abcd' target='_top'>第五集</a>
    登录后复制

    错了?哪里错了?
    我总不能无中生有吧?

    超链接应该是
    youku
    1_1.html
    1_2.html
    1_3.html
    ``````````

    tudou
    2_1.html
    2_2.html
    2_3.html
    ```````````

    down
    3_1.html
    3_2.html
    3_3.html
    `````````

    多个循环输出真不知道要怎么搞

    错了?哪里错了?
    我总不能无中生有吧?

    页面应是真实存在的,应填写在你数据的 abcd 位置
    动态生成的怎么能和真实页面对应起来?

    *_*.html
    (这里是youku tudou down第次的数组)_(这里是各组又重新对应的ID).html

    改成这样的话,就链接名称错了,超链接的数组能不能从1开始算起,不从0算起?


    $a = 'youku$$$tudou$$$down';$b='第一集$abcd第一集$abcd第二集$abcd第三集$abcd第四集$abcd第五集$abcd$$$第六集$abcd第七集$abcd第八集$ddddd第九集$abcd第十集$abcd第十一集$abcd$$$第十二集$abcd第十三集$abcd第十四集$abcd第十五集$abcd第十六集$abcd第十七集$efghijk';$a = explode('$$$', $a);$b = explode('$$$', $b);foreach($a as $i=>$r) {  echo "<li>$r</li>\n";  foreach(explode("\n", $b[$i]) as $v=>$lala) {    $t = explode('$', trim($v));    echo "<a href='".$i."_".$t[0].".html' target='_top'>$t[0]</a>\n";  }}
    登录后复制




    页面应是真实存在的,应填写在你数据的 abcd 位置
    动态生成的怎么能和真实页面对应起来?

    $a = explode('$$$', $a);$b = explode('$$$', $b);foreach($a as $i=>$r) {  echo "<li>$r</li>\n";  foreach(explode("\n", $b[$i]) as $j=>$v) {    $t = explode('$', trim($v));    printf("<a href='%d_%d.html' target='_top'>%s</a>\n", $i+1, $j+1, $t[0]);  }}
    登录后复制
    <li>youku</li><a href='1_1.html' target='_top'>第一集</a><a href='1_2.html' target='_top'>第一集</a><a href='1_3.html' target='_top'>第二集</a><a href='1_4.html' target='_top'>第三集</a><a href='1_5.html' target='_top'>第四集</a><a href='1_6.html' target='_top'>第五集</a><li>tudou</li><a href='2_1.html' target='_top'>第一集</a><a href='2_2.html' target='_top'>第一集</a><a href='2_3.html' target='_top'>第二集</a><a href='2_4.html' target='_top'>第三集</a><a href='2_5.html' target='_top'>第四集</a><a href='2_6.html' target='_top'>第五集</a><li>down</li><a href='3_1.html' target='_top'>第一集</a><a href='3_2.html' target='_top'>第一集</a><a href='3_3.html' target='_top'>第二集</a><a href='3_4.html' target='_top'>第三集</a><a href='3_5.html' target='_top'>第四集</a><a href='3_6.html' target='_top'>第五集</a>
    登录后复制


    但你的数据本该是这样的
    $a = 'youku$$$tudou$$$down';$b='第一集$1_1.html第二集$1_2.html第三集$1_3.html第四集$1_3.html第五集$1_5.html$$$第一集$2_1.html第二集$2_2.html第三集$2_3.html第四集$2_4.html第五集$2_5.html$$$第一集$3_1.html第二集$3_2.html第三集$3_3.html第四集$3_4.html第五集$3_5.html'; $a = explode('$$$', $a);$b = explode('$$$', $b);foreach($a as $i=>$r) {  echo "<li>$r</li>\n";  foreach(explode("\n", $b[$i]) as $v) {    $t = explode('$', trim($v));    echo "<a href='$t[1]' target='_top'>$t[0]</a>\n";  }}
    登录后复制
    <li>youku</li><a href='1_1.html' target='_top'>第一集</a><a href='1_2.html' target='_top'>第二集</a><a href='1_3.html' target='_top'>第三集</a><a href='1_3.html' target='_top'>第四集</a><a href='1_5.html' target='_top'>第五集</a><li>tudou</li><a href='2_1.html' target='_top'>第一集</a><a href='2_2.html' target='_top'>第二集</a><a href='2_3.html' target='_top'>第三集</a><a href='2_4.html' target='_top'>第四集</a><a href='2_5.html' target='_top'>第五集</a><li>down</li><a href='3_1.html' target='_top'>第一集</a><a href='3_2.html' target='_top'>第二集</a><a href='3_3.html' target='_top'>第三集</a><a href='3_4.html' target='_top'>第四集</a><a href='3_5.html' target='_top'>第五集</a>
    登录后复制

    非常感谢

    其实这就一个播放地址,abcd是播放地址,要另做它用

    最佳 Windows 性能的顶级免费优化软件
    最佳 Windows 性能的顶级免费优化软件

    每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

    下载
    来源:php中文网
    本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
    最新问题
    开源免费商场系统广告
    热门教程
    更多>
    最新下载
    更多>
    网站特效
    网站源码
    网站素材
    前端模板
    关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
    php中文网:公益在线php培训,帮助PHP学习者快速成长!
    关注服务号 技术交流群
    PHP中文网订阅号
    每天精选资源文章推送
    PHP中文网APP
    随时随地碎片化学习

    Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号