Jump to content

Associating Arrays


acctman

Recommended Posts

can anyone help me with associating an array. i tried doing something like this list(Array[3] = $m_status, Array[6] = $m_orientation, Array[4] = $m_turn_on, Array[1] = $m_turn_off) = $decode; but that did work.

 

 

the $decode of the array looks like this Array ( [3] => Straight [6] => Involved [4] => text123 [1] => more text ) i'm just trying to re-insert it into the correct fields. I also need assistance with looping through the rows and doing the same for each row in the rate_sys table

 

 

$res = mysql_query("SELECT m_addtn FROM rate_sys WHERE m_id = '39'");
$results = mysql_fetch_array($res,MYSQL_BOTH);

$decode = unserialize(base64_decode($results['m_addtn']));
print_r($decode);

list(Array[3] = $m_status, Array[6] = $m_orientation, Array[4] = $m_turn_on, Array[1] = $m_turn_off) = $decode; 
mysql_query ("UPDATE rate_members SET
             m_status = '$m_status',
             m_orientation = '$m_orientation',
             m_turn_on = '$m_turn_on',
             m_turn_off = '$m_turn_off'
             WHERE m_id = '39'");

Link to comment
https://forums.phpfreaks.com/topic/122133-associating-arrays/
Share on other sites

<?php

list($m_status,$m_orientation,$m_turn_on,$m_turn_off) = $decode;

?>

 

I used to have a problem with the list() function because of it's explanation as a language construct. But, for further information, php.net has a good example to follow from:

 

<?php

$info = array('coffee', 'brown', 'caffeine');

// Listing all the variables
list($drink, $color, $power) = $info;
echo "$drink is $color and $power makes it special.\n";

?>

Link to comment
https://forums.phpfreaks.com/topic/122133-associating-arrays/#findComment-630553
Share on other sites

<?php

list($m_status,$m_orientation,$m_turn_on,$m_turn_off) = $decode;

?>

 

I used to have a problem with the list() function because of it's explanation as a language construct. But, for further information, php.net has a good example to follow from:

 

<?php

$info = array('coffee', 'brown', 'caffeine');

// Listing all the variables
list($drink, $color, $power) = $info;
echo "$drink is $color and $power makes it special.\n";

?>

 

Oh, I tried the List method as well. When I used it, it did not put the array info in the apporiate fields. Is there a why to tell List how to display the Array info ? this is what's inside Array ( [3] => Straight [6] => Involved [4] => text123 [1] => more text ) and some fields only have 8 entries but i only need and want [3], [6], [4], [1]

Link to comment
https://forums.phpfreaks.com/topic/122133-associating-arrays/#findComment-630608
Share on other sites

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.