i have an array, it have same data:
data range
115X0101-115X0200
115X0101-115X0200
115X0101-115X0200
the 115x mean production code..this unimportant.
we just concern at four digits behind it that we can counting.
1. i want script read or search "0101" and "0200" from 115X0101-115X0200
2. i have tried using regex to count them become 200-101=100
3. the "115X0101-115X0200" repeated until there are 20 data like this
4. after it reached 20, show result at page:
data range
100
If this is the raw data, the easiest way to extract it is probably using a regular expression, as you’ve mentioned.
You’ll probably want something like this (in PHP):
For each row, preg_match will find groups of 4 digits (
\d{4}) and place them in$matches(usevar_dump($matches)to see what it looks like).More on Regex
SQL Limit
Side note: If you only want 20 results at a time, you’ll want to
SELECT * FROM table LIMIT 20when you query the database. To get rows 31-50 you’d useLIMIT 30, 20, which means offset by 30, then get 20 rows.