WordPress.org

Ready to get started?Download WordPress

Forums

shortcode capture not working. (2 posts)

  1. Joshua
    Member
    Posted 2 years ago #

    Hey,

    I am trying to populate an option dropdown based on an array generated from a shortcode. The shortcode is an official InfusionWP code. Currently the code looks like this:

    ob_start();
    //    echo '1234, 4321, 5678, 8765';
      echo '[i4w_db__HalifaxonlineAcNumber]';
      $accno = ob_get_contents();
    ob_end_clean();
    $clean = str_replace(" ", "", $accno);
    echo '$clean: ' . gettype($clean) . '= '.$clean.'<br />';
    $exploded = explode(",",$clean);
    echo '$exploded: ' . gettype($exploded) . '= ' .$exploded. '<br />';
    print_r($exploded);

    to wit it outputs:

    $clean: string= 123456, 654321, 852963
    $exploded: array= Array
    Array
    (
    [0] => 123456, 654321, 852963
    )

    As you will notice the output should return a 4 row array. If I set the output to the remmed out line and rem out the other line it outputs as expected.

    What is wrong with said array

  2. vtxyzzy
    Member
    Posted 2 years ago #

    First guess - the string is in a different character set than the code. Neither the str_replace or the explode matched.

    See the PHP manual, especially these functions:

    http://www.php.net/manual/en/function.utf8-decode.php

    http://php.net/manual/en/function.mb-detect-encoding.php

Topic Closed

This topic has been closed to new replies.

About this Topic