Need help trying to remove a array value (Customer ID) from a attribute array value in a collection
//unfollowAction //Get Model to save data to. $model = Mage::getModel("userprofiles/userprofiles"); $model->getCollection()->addFieldToFilter('userprofiles_id', $id); $model->setUserprofilesId($id); //Get Model to fetch data from $model2 = Mage::getModel("userprofiles/userprofiles")->load($id); //Build Array output is 123,234,345,456, $FollowProfilesArray = array($model2->getFollowProfiles()); //Remove specified ID from array, $profile_id equals current customer ID $remove_from_array = array_diff($FollowProfilesArray, array($profile_id,)); foreach($remove_from_array as $key => $value){ $select .= ''.$value.','; } //save new array to attribute value with the specified ID removed. $model->setFollowProfiles($select); Problem is that this code is not removing the specified ID and saving the attribute value as 123,234,345,,
Note:
$model2->getFollowProfiles() output/saved value is 123,234,345,456 etc
the code $FollowProfilesArray = array($model2->getFollowProfiles()); does not work as stated above but if it hardcode the array data to
//Works,but not ideal or relevant $FollowProfilesArray = array(123,234,345,456,); So is there something im missing like exploding or imploding the $FollowProfilesArray = array($model2->getFollowProfiles()); code