Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6581717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:11:21+00:00 2026-05-25T16:11:21+00:00

i looking to make a small script that will understand pagination of urls i

  • 0

i looking to make a small script that will understand pagination of urls i input and advance the pagination forever.

my input example, 2 strings:

hello14.com/14/oijosij
hello14.com/15/oijosij

script should output:

hello14.com/14/oijosij
hello14.com/15/oijosij
hello14.com/16/oijosij
hello14.com/17/oijosij
hello14.com/18/oijosij
hello14.com/19/oijosij

and forever and forever.

it must be able to handle many variations of urls, not just this spesific case.

if you look at my code below, you see where i run into trouble.
it detects if there IS pagination in the urls, but i dont know how to detect the right position of where the pagination is located.
i cannot just explode the pagination number found, that will result in error, as my example contains the first pagination-number also elsewhere in the url.

$string1 = "hello14.com/14/oijosij";
$string2 = "hello14.com/15/oijosij";

// match all spans of numbers
preg_match_all("/[0-9]{1,}/", $string1, $out);
preg_match_all("/[0-9]{1,}/", $string2, $out2);

// loop through all spans of numbers found in string 1
for ($loop = 0; $loop < count($out[0]); $loop++) {
  if ($out2[0][$loop] - $out[0][$loop] == 1) {
    echo "we have pagination. ".$out[0][$loop]." and ".$out2[0][$loop];
    // but how can i go about it here?
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:11:21+00:00Added an answer on May 25, 2026 at 4:11 pm

    I’m sure there must be a very different&easier approach to this, but I did what I could with what I knew

     <?php
        //into an ugly function...
        function get_structure($str1, $str2){
            preg_match_all("/\d+/",$str1, $out1);
            preg_match_all("/\d+/",$str2, $out2);
            $parts = preg_split("/\d+/",$str1);
            $total = count($out1[0]);
            for($i=0;$i<$total;$i++){
                if($out2[0][$i] - $out1[0][$i] == 1){
                    $left = "";
                    for($j=0;$j<=$i;$j++){
                        $left .= $j == $i ? $parts[$j] : $parts[$j].$out1[0][$j];
                    }
                    $right = "";
                    for($j=$i+1;$j<=$total;$j++){
                        $right .= $j == $total ? $parts[$j] : $parts[$j].$out1[0][$j];
                    }
                    return array($left, $right, $out2[0][$i]);
                }   
            }
            return false;
        }
    
    
        //using it
        $str1 = "13hello1415duh.com/2011/13/yay";
        $str2 = "13hello1415duh.com/2011/14/yay";
        if($parts = get_structure($str1, $str2)){
            list($left,$right,$number) = $parts;
            while($number < 30){ //it has to stop..
                $number++;
                echo $left.$number.$right."<br>";
            }
        }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking to make a website that will probably get some heavy, repetitive traffic.
I'm going to make a small application for a business that will be used
I am in the process of makeing a small script that will take all
Basically, what I'm trying to do is simply make a small script that accesses
I'm looking to make a simple web traffic sniffer that will automatically reply to
Im trying to make a small app in c++ that saves midifiles with this
I am looking to create a small encrypted string, like the referral strings used
I'm writing a small script that gathers a couple exif values from images... namely
I am trying to make a small game like app that has some interaction,
I wrote a small PHP application that I'd like to distribute. I'm looking for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.