Php 检查++;存在,如果不存在,则获取最近的

Php 检查++;存在,如果不存在,则获取最近的,php,Php,对于该部分$next\u post=$number+1每次我点击一个按钮,向前走一步,但当它达到$number=2它将给我404错误,因为没有$number=3如何键入查询以检查下一个数字是否不存在,然后直接跳转到最近的数字。将数字放入数组: [ number - title ] [ 1 - t1 ] [ 2 - t2 ] [ 5

对于该部分
$next\u post=$number+1每次我点击一个按钮,向前走一步,但当它达到
$number=2它将给我404错误,因为没有
$number=3如何键入查询以检查下一个数字是否不存在,然后直接跳转到最近的数字。

将数字放入数组:

[     number      -      title     ]
[        1        -        t1      ]
[        2        -        t2      ]
[        5        -        t3      ]
[       13        -        t4      ]
[       22        -        t5      ]

现在您可以使用
$next_post=$number[$i+1]

将您的号码放入一个数组:

[     number      -      title     ]
[        1        -        t1      ]
[        2        -        t2      ]
[        5        -        t3      ]
[       13        -        t4      ]
[       22        -        t5      ]

现在您可以使用
$next_post=$number[$i+1]

您是否可以使用正则表达式将数字预处理为一个数组,然后使用$next_post=$array[i]作为数组的大小array@brad,hm,正则表达式?正则表达式,用于提取[和-,然后你可以将它们存储在一个数组中,比如:?你可以使用正则表达式将数字预处理到一个数组中,然后使用$next_post=$array[i]作为数组的大小吗array@brad,hm,regex?regex,正则表达式,用于提取[and-]之间的数字,然后您可以将这些数字存储在如下数组中:?