[ create a new paste ] login | about

Link: http://codepad.org/6rT0pfno    [ raw code | output | fork | 1 comment ]

PHP, pasted on Dec 30:
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
function removeFromString($str, $item) {
    $parts = explode(',', $str);

    while(($i = array_search($item, $parts)) !== false) {
        unset($parts[$i]);
    }

    return implode(',', $parts);
}

echo removeFromString('one,two,three,four', 'two');
?>


Output:
1
one,three,four


Create a new paste based on this one


Comments:
posted by JoshLambert on Sep 26
Hey, this is nice. Thank you for posting this. (Found from the link on Stackoverflow.)
reply