split - PHP: Text explode() problem -


i have problem explode() function. use function explode strings "name: replica" in string has 2 or more colons ( ":" ) , there problem because script is: example: "name: replica:replica2:replica3"

$explode = explode(":", $string); $query = "insert `table` (`field_1`, `field_2`) values ('".$explode[0]."', '".$explode[1]."')"; 

and need solution problem. because when split string after first colon ( ":" ) second part must last part.

regards, george!

p.s. - sorry english.

i think want use 'limit' (third) argument explode():

list($attribute, $value) = explode(":", $string, 2); 

that make sure 2 results.

http://php.net/manual/en/function.explode.php


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -