Chciałbym podmienić wszystkie dane w tablicy na własne , jednak mój pomysł podmienia tylko ostatnią wartość klucza
Kod
<?php
$v = isset($_GET['v']) ? $_GET['v'] : '10';
$k = isset($_GET['k']) ? $_GET['k'] : '6';
$t = isset($_GET['t']) ? $_GET['t'] : '4';
$v = ceil($v);
$k = ceil($k);
$t = ceil($t);
$array = [1 => 41, 51, 61, 71, 81, 91, 11, 22, 33, 45];
//$licz = (count($array));
$url = "http://ljcr.dmgordon.org/show_cover.php?v=$v&k=$k&t=$t";
$content = file_get_contents($url);
$first_step = explode('<pre width=80>', $content);
$second_step = explode("</pre>", $first_step[1]);
$text = $second_step[0];
print_r($text);
$list = explode("\n", $text);
$list = preg_replace('/ /', '', $list, 1);
$string_array = preg_replace("/[[:blank:]]+/", ",", $list);
$filtered_array = array_filter($string_array);
if ($k >= $t && $v > $k && $k <= 10 && $t <= 8 && $v <= 20)
{
foreach ($array as $a => $b)
{
foreach ($filtered_array as $c)
{
$d = explode(',', $c);
$f = str_replace($a, $b, $d);
}
}
}
print_r($f);
Array
(
[0] => 1
[1] => 2
[2] => 4
[3] => 7
[4] => 9
[5] => 45
)
$v = isset($_GET['v']) ? $_GET['v'] : '10';
$k = isset($_GET['k']) ? $_GET['k'] : '6';
$t = isset($_GET['t']) ? $_GET['t'] : '4';
$v = ceil($v);
$k = ceil($k);
$t = ceil($t);
$array = [1 => 41, 51, 61, 71, 81, 91, 11, 22, 33, 45];
//$licz = (count($array));
$url = "http://ljcr.dmgordon.org/show_cover.php?v=$v&k=$k&t=$t";
$content = file_get_contents($url);
$first_step = explode('<pre width=80>', $content);
$second_step = explode("</pre>", $first_step[1]);
$text = $second_step[0];
print_r($text);
$list = explode("\n", $text);
$list = preg_replace('/ /', '', $list, 1);
$string_array = preg_replace("/[[:blank:]]+/", ",", $list);
$filtered_array = array_filter($string_array);
if ($k >= $t && $v > $k && $k <= 10 && $t <= 8 && $v <= 20)
{
foreach ($array as $a => $b)
{
foreach ($filtered_array as $c)
{
$d = explode(',', $c);
$f = str_replace($a, $b, $d);
}
}
}
print_r($f);
Array
(
[0] => 1
[1] => 2
[2] => 4
[3] => 7
[4] => 9
[5] => 45
)
Na tym moje skromne pomysły się kończą. Czy może ktoś pomóc i naprowadzić mnie co robię nie tak?