doudiewen9435 2017-08-19 22:34
浏览 27
已采纳

PHP在特定页面的指定字符串后获得5个附加字符并列出它们

Note: I have edited the post on 2017/08/20

I'm trying to obtain a list of product page's URL that goes "www.example.com/product/11111/".

There are over 200 different products available and each of them has its own product page, I want to print out each product in a PDF file.

On "www.example.com/productlist/", there are URLs that lead to each product's page.

So, what I'm trying to do is

  1. Obtain URLs that I need from "www.example.com/productlist/"
  2. Generate PDF files of URLs that I have obtained
  • 写回答

2条回答 默认 最新

  • dpi10335 2017-08-20 00:19
    关注

    Insufficient Information: You did not provide me with much information about the code you already have and how the website will get the 200 URLs, so I can't write the whole code because it depends on the way your website will get the links from.

    If you explain more about how the website is supposed to get the links, I will help you put them into an array and save them into a file and implement the rest of the code!

    1-) Thing I understood is getting the last 5 characters

    As you just want the last 5 characters, not the whole last part, you can do something like this.

        $string = "http://example.com/folder/example/1234567"; //your link
        $characters = strlen($string);  //gets the characters count
        $letters = 5;  //edit 5 to show more or less manually
        $code = substr($string, $characters - $letters, $characters);
    
        echo $code; //will show the last 5 characters 
    

    I am always here to help. Good luck!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程