Site icon Hip-Hop Website Design and Development

Return an array from get_terms and retailer as JavaScript array for search autocomplete

I’m making an attempt to make use of wp_list_pluck to return an array of taxonomy names from get_terms. I am unsure what I am doing incorrect, however this solely echo’s out “Array”:

$phrases = get_terms(array(
        'taxonomy' => 'state',
        'hide_empty' => false,
    ));

    $term_ids = wp_list_pluck( $phrases, 'title' );

    echo $term_ids;

Are you aware how I can echo out an array of taxonomy names?

The rationale I’m doing it’s because I’m desirous to get an array to transform it to a Javascript array of names utilizing json_encode.

Principally I am utilizing jQuery Autocomplete and want to get my taxonomy names listed as options to seek for:

var availableTags = <?php echo json_encode( $term_ids ) ?>

Maybe there may be presumably a greater strategy to obtain what I’m making an attempt to do? Thank-you.