mirror of
https://github.com/YGGverse/gemini-php.git
synced 2026-03-31 17:05:29 +00:00
return match line number as the array key in result
This commit is contained in:
parent
55b13c4031
commit
526d810406
1 changed files with 10 additions and 10 deletions
|
|
@ -20,11 +20,11 @@ class Body
|
||||||
{
|
{
|
||||||
$matches = [];
|
$matches = [];
|
||||||
|
|
||||||
foreach ($this->_lines as $line)
|
foreach ($this->_lines as $index => $line)
|
||||||
{
|
{
|
||||||
if (preg_match('/^#([^#]+)/', trim($line), $match))
|
if (preg_match('/^#([^#]+)/', trim($line), $match))
|
||||||
{
|
{
|
||||||
$matches[] = trim(
|
$matches[$index] = trim(
|
||||||
$match[1]
|
$match[1]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -37,11 +37,11 @@ class Body
|
||||||
{
|
{
|
||||||
$matches = [];
|
$matches = [];
|
||||||
|
|
||||||
foreach ($this->_lines as $line)
|
foreach ($this->_lines as $index => $line)
|
||||||
{
|
{
|
||||||
if (preg_match('/^##([^#]+)/', trim($line), $match))
|
if (preg_match('/^##([^#]+)/', trim($line), $match))
|
||||||
{
|
{
|
||||||
$matches[] = trim(
|
$matches[$index] = trim(
|
||||||
$match[1]
|
$match[1]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -54,11 +54,11 @@ class Body
|
||||||
{
|
{
|
||||||
$matches = [];
|
$matches = [];
|
||||||
|
|
||||||
foreach ($this->_lines as $line)
|
foreach ($this->_lines as $index => $line)
|
||||||
{
|
{
|
||||||
if (preg_match('/^###([^#]+)/', trim($line), $match))
|
if (preg_match('/^###([^#]+)/', trim($line), $match))
|
||||||
{
|
{
|
||||||
$matches[] = trim(
|
$matches[$index] = trim(
|
||||||
$match[1]
|
$match[1]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -71,11 +71,11 @@ class Body
|
||||||
{
|
{
|
||||||
$matches = [];
|
$matches = [];
|
||||||
|
|
||||||
foreach ($this->_lines as $line)
|
foreach ($this->_lines as $index => $line)
|
||||||
{
|
{
|
||||||
if (preg_match('/^=>(.*)/', trim($line), $match))
|
if (preg_match('/^=>(.*)/', trim($line), $match))
|
||||||
{
|
{
|
||||||
$matches[] = trim(
|
$matches[$index] = trim(
|
||||||
$match[1]
|
$match[1]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -88,11 +88,11 @@ class Body
|
||||||
{
|
{
|
||||||
$matches = [];
|
$matches = [];
|
||||||
|
|
||||||
foreach ($this->_lines as $line)
|
foreach ($this->_lines as $index => $line)
|
||||||
{
|
{
|
||||||
if (preg_match('/' . $protocol . ':\/\/(.*)[\s\S\'"]*/', trim($line), $match))
|
if (preg_match('/' . $protocol . ':\/\/(.*)[\s\S\'"]*/', trim($line), $match))
|
||||||
{
|
{
|
||||||
$matches[] =
|
$matches[$index] =
|
||||||
sprintf(
|
sprintf(
|
||||||
'%s://%s',
|
'%s://%s',
|
||||||
$protocol,
|
$protocol,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue