Jump to content

Splilting a variable


jay_bo

Recommended Posts

You can try figuring out how you want to split up the variable - is it with spaces, some character (+,-,=,!,etc). If you have any code to show, we might be able to help, but your request is extremely vague.

 

Try looking up: Str_Split; if you want to use regular expressions, there's preg_split; or if you use an array, you can try explode.

Yea i want to splilt it up by spaces..... this is my code

 

if(is_array($_SESSION['cart'])){
            	echo '<tr bgcolor="#FFFFFF" style="font-weight:bold; color:#FFF; background-image:url(media/images/site/shopping_table_bg.jpg); background-repeat:repeat;""><td>Products</td><td>Name</td><td>Price</td><td>Qty</td><td>Amount</td><td>Options</td></tr>';
			$max=count($_SESSION['cart']);
			for($i=0;$i<$max;$i++){
				$pid=$_SESSION['cart'][$i]['productid'];
				$q=$_SESSION['cart'][$i]['qty'];
				$pname=get_product_name($pid);
				if($q==0) continue;

 

I'm wanting to spilit up $q so that i can add up all the numbers in that variable... when i echo the variable it displays 1 1 4

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.