vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   why isn't this unsetting? (https://vborg.vbsupport.ru/showthread.php?t=121968)

sabret00the 07-24-2006 12:00 PM

why isn't this unsetting?
 
PHP Code:

        echo "<pre>";
        
print_r($formdetails['taglist']);
        echo 
"</pre>";

        foreach (
$formdetails['taglist'] AS $k)
        {
            if (
$k == $tagtodelete)
            {
                echo 
$k $tagtodelete;
                unset(
$formdetails['taglist'][$k]);
            }
        }
        echo 
"<pre>";
        
print_r($formdetails['taglist']);
        echo 
"</pre>";
        die; 

Code:

Array
(
    [0] => admining
    [1] => amazon
    [2] => another tag
    [3] => ebs
    [4] => ex-girlfriend
    [5] => life
    [6] => meme
    [7] => music
    [8] => retest
    [9] => singledom
    [10] => test
    [11] => test again
    [12] => wishlist
    [13] => work
)

retestretest

Array
(
    [0] => admining
    [1] => amazon
    [2] => another tag
    [3] => ebs
    [4] => ex-girlfriend
    [5] => life
    [6] => meme
    [7] => music
    [8] => retest
    [9] => singledom
    [10] => test
    [11] => test again
    [12] => wishlist
    [13] => work
)

i even tried
PHP Code:

        echo "<pre>";
        
print_r($formdetails['taglist']);
        echo 
"</pre>";

        foreach (
$formdetails['taglist'] AS $k => $v)
        {
            if (
$v == $tagtodelete)
            {
                echo 
$v $tagtodelete;
                unset(
$formdetails['taglist'][$tagtodelete]);
            }
        }
        echo 
"<pre>";
        
print_r($formdetails['taglist']);
        echo 
"</pre>";
        die; 


amykhar 07-24-2006 02:16 PM

I THINK it should be :

Code:

echo "<pre>";
        print_r($formdetails['taglist']);
        echo "</pre>";

        foreach ($formdetails['taglist'] AS $k => $v)
        {
            if ($v == $tagtodelete)
            {
                echo $v . $tagtodelete;
                unset($formdetails['taglist'][$k]);
            }
        }
        echo "<pre>";
        print_r($formdetails['taglist']);
        echo "</pre>";
        die;


sabret00the 07-24-2006 02:23 PM

thanks amy, i'll give it a whirl :)

AN-net 07-24-2006 04:28 PM

or an array flip will work if you just process the element value.

sabret00the 07-24-2006 05:31 PM

alternatively for anyone else baffled by this in the future (probably me).
PHP Code:

        $tagtodelete urldecode($_POST['tagdelete']);

        
$formdetails['taglist'] = explode(','$formdetails['taglist']);

        unset(
$formdetails['taglist'][array_search($tagtodelete$formdetails['taglist'])]);
        
$formdetails['taglist'] = implode(','array_values($formdetails['taglist'])); 



All times are GMT. The time now is 03:50 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02395 seconds
  • Memory Usage 1,737KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete