#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2011
    Posts
    14
    Rep Power
    0

    Adding a 3rd dimension to an array


    I am trying to add the $country array to the array and cant seem to get it right. I am sure it needs to be a multidimentional array which in php is an array within an array but i have tried a lot of combinations and they are not right.
    Code:
    if ( empty( $_POST['wpsc_shipping_weightrate_shipping'] ) || empty( $_POST['wpsc_shipping_weightrate_layer'] ) || empty($_POST['wpsc_shipping_weightrate_country'] ) )
    	return false;
    
    		$new_layers = array();
    		$layers = (array)$_POST['wpsc_shipping_weightrate_layer'];
    		$shippings = (array)$_POST['wpsc_shipping_weightrate_shipping'];
    		$country = (array)$_POST['wpsc_shipping_weightrate_country'];
    		if ( !empty($shippings) ) {
    //i would believe this is where i need to do it but am 
    //unsure as to how to go about it
    			foreach ($shippings as $key => $price) {
    				if ( empty( $price ) || empty( $layers[$key] ) )
    					continue;
    //and then this would have to change as well
    				$new_layers[$layers[$key]] = $price;
    				
    			}
    
    		}
    
    		krsort( $new_layers );
    		update_option( 'weight_rate_layers', $new_layers );
    		return true;
    	}
  2. #2
  3. Banned
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,938
    Rep Power
    0
    Gotta love those questions ...

    Could you please try to explain the situation and what you're trying to do? Keep in mind that we can neither read your mind, nor were we involved in the previous thought process. We know nothing but the code you give us, and this one doesn't even have a "$country array".
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2011
    Posts
    14
    Rep Power
    0
    Originally Posted by Jacques1
    Gotta love those questions ...

    Could you please try to explain the situation and what you're trying to do? Keep in mind that we can neither read your mind, nor were we involved in the previous thought process. We know nothing but the code you give us, and this one doesn't even have a "$country array".
    I fixed it myself i just used combining arrays and just so you know the $country array is at the top which is cast, i.e.
    Code:
    $country = (array)$_POST['wpsc_shipping_weightrate_country'];
    Thanks for looking.

IMN logo majestic logo threadwatch logo seochat tools logo