• Resolved herculesnetwork

    (@herculesnetwork)


    [moved to Developing WordPress. Please use this for any coding questions. The old Plugins and Hacks forum is no longer in use.]

    A list of denied words, with a condition only if glued with symbols

    //my arrays

    
              $Rejected_symbols = array('*','#','-','!','?','+','=','¨','^','~','@');
              $Rejected_if_with_symbols = array('t1','t2','t3','t4');
    

    // my search 1 – symbols always rejecteds

    
                $search = $Rejected_symbols;
                $replace = array('Forbidden symbol','Forbidden symbol','Forbidden symbol','x','x','x','x','x','x','x','x');
             (my-function) 
    

    // my search 2 – Words rejecteds, if theys are glueds with symbols

    
               $search = $Rejected_if_with_symbols;
               $replace = array('Prohibited combination','Prohibited combination','Prohibited combination','Prohibited combination'); 
            (my-function) 
    

    // my search 3, words always rejecteds and your array.

    
              $search = array('string1','string2','string3','string4');
             $replace = array('forbiten word','forbiten word','forbiten word','forbiten word');
             (my-function) 
    

    In the first search, success, the forever prohibited symbols,
    In the third search, success, words that do not desire are always forbidden.
    But in SECOND search, words are always denied, and these are important must pass, only can be denied if they are glued with simbols in the first array.

    this words: (‘t1′,’t2′,’t3′,’t4’); in seatch 2 Are always being denied, and I do not want this, I want them denied only if they are glued with symbols:

    %t1 ou ?t1 ou +t1 etc..

Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter herculesnetwork

    (@herculesnetwork)

    Among my dozens of attempts, this was the result ??

    
    $Var1 = array('my1','my2','my3');
    $Var2 = array('word1','word2','word3');
    $result = array();
    $result = array_map( $Var1, $Var2 );
        foreach (explode($Var1) as $w1) {
        foreach (explode($var2) as $w2) {
            $result[] = $w1 . $w2; 
            //$result = trim($w1) . trim($w2);
        }
    }
    print_r($result);
    $mytextfield = str_replace( $result, '[redacted]', $mytextfield );
    

    I tried it as a function as well, but I do not think it needs to:

    
    function gluedingarray()
    {
    $Var1 = array('my1','my2','my3');
    $Var2 = array('word1','word2','word3');
    $result = array();
    $result = array_map("gluedingarray", $Var1, $Var2 );
        foreach (explode($Var1) as $w1) {
        foreach (explode($var2) as $w2) {
            $result[] = $w1 . $w2; 
            //$result = trim($w1) . trim($w2);
        }
    }
    }
    print_r($result);
    $mytextfield = str_replace( $result, '[redacted]', $mytextfield );
    

    Where is my mistakes?

    Thread Starter herculesnetwork

    (@herculesnetwork)

    Oops, explode with arrays not..

    
    $Var1 = array('my1','my2','my3');
    $Var2 = array('word1','word2','word3');
    $result = array();
    $result = array_map($Var1, $Var2 );
        foreach ($Var1 as $w1) {
        foreach ($Var2 as $w2) {
        $result[] = $w1 . $w2;
        }
    }
    print_r($result);
    $mytextfield = str_replace( $result, 'Disallow entries', $mytextfield );
    

    Now is it a little better?

    Thread Starter herculesnetwork

    (@herculesnetwork)

    I did this edition right here, and when I went to test in the script, it worked !!!
    THANKS BCWorkZ, another plugin ready to hone, streamline my production in content creation ??

    Moderator bcworkz

    (@bcworkz)

    You’re welcome!

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘A list of denied words, with a condition only if glued with symbols’ is closed to new replies.