Answer the question
In order to leave comments, you need to log in
How can I find pages that contain certain text from a list of urls?
Hello, I have the following task:
There is a txt file with a list of url types (100k lines) without http:// and https://
site.com/123.php
site2.info/456.php
Answer the question
In order to leave comments, you need to log in
something like this?
#!/bin/bash
while read; do
echo "processing the following string: ${REPLY}"
if curl ${REPLY} |grep "Statistic and a Parameter"; do
echo "${REPLY}" >> urls_with_text.txt
done
done<file_with_urls.txt
<?php
$array = [
[
'player_id' => 1,
'count_goals' => 1
],
[
'player_id' => 1,
'count_goals' => 1
],
[
'player_id' => 1,
'count_goals' => 1
],
[
'player_id' => 1,
'count_goals' => 1
],
];
function filter($array)
{
$result = [];
foreach($array as $key => $value) {
if (array_key_exists($value['player_id'], $result)) {
$result[$value['player_id']]['count_goals'] += $value['count_goals'];
} else {
$result[$value['player_id']] = $value;
}
}
return array_values($result);
}
print_r(filter($array));
Andrey
in the course of work noticed that when there are more values in the array than 2 i.e.:
$array = [
[
'player_id' => 1,
'count_goals' => 1
],
[
'player_id' => 1,
'count_goals' => 1
],
[
'player_id' => 1,
'count_goals' => 1
],
[
'player_id' => 1,
'count_goals' => 1
],
];
array(
(int) 0 => array(
'player_id' => '1',
'count_goals' => (int) 3
),
(int) 1 => array(
'player_id' => '1',
'count_goals' => (int) 1
)
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question