php - array_map and trim not trimming white space from values -


this function below returns string of values comma separated

$key_1_value = get_post_meta(422,'keywords',true);

the output in browser looks red, white, blue, blue 2 , green, yellow, purple, magenta , cyan, black

i'm trying trim white space before , after values.

so used code try , trim whitespace it's still there. why won't trim values?

$test = array($key_1_value); $trimmed_array=array_map('trim',$test); print_r($trimmed_array); 

$key_1_value string representation , not array or string quoted values, have explode array items, , not put inside array call, becomes proper array

$test = explode(",",$key_1_value); $trimmed_array=array_map('trim',$test); print_r($trimmed_array); 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -