Terrorist Man Terrorist Man - 1 year ago 142
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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download