Home > Mobile >  Php explode loop up to value
Php explode loop up to value

Time:11-25

I want to break the line I pulled from the database and list the ip addresses

Sql Table export a:3{i:0;s:13:"213.74.219.18";i:1;s:13:"321.32.321.32";i:2;s:14:"321.315.212.55";}

$set=mysqli_query($con,"SELECT * FROM simple_stats_options where option='ignored_ips'");
$value = mysqli_fetch_array($set,MYSQLI_ASSOC);

function arasinial($str,$birinci,$ikinci,$i) {
   $bolum = explode ($birinci,$str); 
   $bolum = explode ($ikinci,$bolum[$i]); 
   return $bolum[0];
}

$array = explode('/', $var);
foreach ($array as $values)
{

}
$metin=$value["value"];

for ($x = 1; $x <= 10; $x  ) {
 echo arasinial($metin,':"','";',$x)."<br>";
}

CodePudding user response:

Your data is serialized data, so you can just use unserialize():

<?php
$r = 'a:3:{i:0;s:13:"213.74.219.18";i:1;s:13:"321.32.321.32";i:2;s:14:"321.315.212.55";}';
print_r(unserialize($r));

will output

Array
(
    [0] => 213.74.219.18
    [1] => 321.32.321.32
    [2] => 321.315.212.55
)
  •  Tags:  
  • php
  • Related