Wednesday, November 23, 2022
HomeWordPress Developmentphp - How you can minimize a bit of a URL from...

php – How you can minimize a bit of a URL from a string with an everyday expression?


I’m pulling a response from an API utilizing PHP to show a listing of content material on my WordPress web site from an exterior service. The best way they’ve their API arrange, I have to create a loop that checks if there’s a “subsequent web page” of information that I can entry. The API returns a header merchandise known as “Hyperlinks”, with the next content material:

<https://exterior.service.com/myusername/api/alternatives>; rel="first",<https://exterior.service.com/myusername/api/alternatives?earlier than=512a7905-65a3-4845-bb8f-d2363c9e1d95>; rel="prev",<https://exterior.service.com/myusername/api/alternatives?after=2ab72e09-82d9-4c80-a3bb-4a2fea248695>; rel="subsequent"

I can use the “Subsequent” hyperlink to name the API once more, which provides me the subsequent web page of information. A bit odd, however that is the way in which they’ve their API arrange…not a lot I can do about it.

I am assuming the easiest way to do that is through the use of an everyday expression to repeat the “Subsequent” hyperlink to a variable, and create a loop which calls the hyperlink saved within the variable, updating it every time. I am having bother arising with the common expression that might do that, although. Is it attainable to do with out it catching the opposite three hyperlinks as effectively?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments