News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

implode Array problem

Started by The Wizard, August 21, 2012, 03:41:42 PM

Previous topic - Next topic

emanuele

Why do you want to implode it at all costs?
You don't need to! ;)


$W = implode(',', $row);

That piece is just useless: $row is yes an array (apart that you could even retrieve it as a simple string, but that's for later :)), but if you use $row['wizard'] you'll obtain the string without have to implode anything.
So:
function onUse()
{
global $smcFunc, $db_prefix, $user_info;

// Get the user's information from the database

    $result = $smcFunc['db_query']('', "
    SELECT wizard
    FROM {db_prefix}members
    WHERE id_member = {int:current_member}
    LIMIT 1",
    array(
      'current_member' => $user_info['id'],
    ));

    // fetch their information

$row = $smcFunc['db_fetch_assoc']($result);

// add your value to the array - in this case its image12

    $B = $row['wizard'] . (!empty($row['wizard']) ? ',' : '') . 'image12';

// Save all the orginal image names plus the new value

    updateMemberData($user_info['id'], array('wizard' => $B));

    return '<br>You now own 12 long-stem roses.<br /><br />We here at Acme Florists division hopes that they will brighten your day.<br />
    <br />Enjoy<br />
        <br />Acme Division Products Company<br /><br />';

}


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Advertisement: