Terrorist Man Terrorist Man - 17 days ago 5x
PHP Question

PHP seperate string based on Charracters||||||

I am trying to figure out a way I can phase a string of data from a url to separate each entry based on the character |

Anyone got any ideas? PHP


You can use the explode() function to split the string and remove empty elements with array_filter()

$string = '||||||';
$ips = array_filter(explode('|', $string));

which results in an array containing all your ip adresses

    [0] =>
    [1] =>
    [2] =>
    [3] =>
    [4] =>
    [5] =>

There are also two other functions, split() and preg_split() which supports regular expressions too.