Stripping commas out of PHP


Staff member
I have a dynamic value that is being stored in a PHP variable. The variable holds a string of data that represents which check-boxes were clicked. It is returned like so: Option1, Option2, Option3, Option4.....

I would like to strip out the commas so it is just Option1 Option2 Option3 Option4....

My Code:

    $type = the_field('type_of_work'); 
    $type = str_replace(",", "",$type);
    echo $type; 

For some reason, the commas are still being rendered. Any idea why or how I can fix this? Just so you know, the_field('type_of_work') is a way to pull advanced custom fields from wordpress' backend, but shouldn't be relevant to this question as it is retuning a string with commas successfully. Any thoughts?

UPDATE: I am going about this a different way like so:

if(in_array('brand-id', get_field('type_of_work') )): 
    echo "brand-id";

echo " ";

if(in_array('print', get_field('type_of_work') )): 
    echo "print";

so on....