View Full Version : Breaking up Field Value (doable?)

11-30-2006, 10:07 PM
"$cart" is being submitted to a form, but it contains information that I need to break apart and have separate field names for (i.e. $cart[0], $cart[1], $cart[3]).

The format it is being submitted as (keep in mind the form is coming to my php file but not from anything I control, I really do need a workaround) a format that I believe this should be doable. A sample $cart is submitted looking like this:
This Product : 2 : 52.00

See the good thing is each item I need individually is separated by " : ", so is there a way to pull this apart to =

$cart[0] = "This Product"
$cart[1] = "2"
$cart[2] = "52.00"

Thanks in advance.

11-30-2006, 10:39 PM
Try the split() (http://us2.php.net/manual/en/function.split.php) function. It allows you to "split" a string with a delimiter...the ':' in your string.


$cart = "Product : 2 : 52.00";

$cartArray = split(":", $cart);

11-30-2006, 10:44 PM
thank you.