Matheus Grilo
Matheus Grilo

Reputation: 9

How to use more than one explode

i actually don't have any idea how to do this, my code is this

$a = explode("/", $row['table']);
if(count($a)>1) {
echo implode('', $a);

}
else {
    echo $row['table'];
}

but, i don't want only to explode "/", i would like to explode "/", ":", "<", ">" (examples)

It's possible?

Upvotes: 0

Views: 62

Answers (1)

Snow Blind
Snow Blind

Reputation: 1164

First replace all ":", "<" and ">" etc. with "/" and then explode "/".

$array = array(":", "<", ">");

foreach($array as $delimeter){
    $row['table'] = str_replace($delimeter, "/", $row['table']);
}

$a = explode("/", $row['table']);
if(count($a)>1) {
echo implode('', $a);

}
else {
    echo $row['table'];
}

Upvotes: 1

Related Questions