acctman Posted August 31, 2008 Share Posted August 31, 2008 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 More sharing options...
kratsg Posted August 31, 2008 Share Posted August 31, 2008 <?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 More sharing options...
acctman Posted August 31, 2008 Author Share Posted August 31, 2008 <?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 More sharing options...
acctman Posted September 1, 2008 Author Share Posted September 1, 2008 anyone know how to capture the array for input the way I listed it in the post above this one? Link to comment https://forums.phpfreaks.com/topic/122133-associating-arrays/#findComment-630681 Share on other sites More sharing options...
kratsg Posted September 2, 2008 Share Posted September 2, 2008 Just put fake variables in the spots you don't want o_o Link to comment https://forums.phpfreaks.com/topic/122133-associating-arrays/#findComment-631555 Share on other sites More sharing options...
acctman Posted September 2, 2008 Author Share Posted September 2, 2008 i figured it out myself by using $decode[index] i was able to select which part of the array to grab. Link to comment https://forums.phpfreaks.com/topic/122133-associating-arrays/#findComment-631594 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.