I have the following values:
$attached_products = "1,4,3";
I want to make an array that looks like:
$selected = array(1, 4, 3);
using a loop with my $attached_products.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This could be done with a loop, but there’s a simpler way.
You can break your string up around the commas using the
explodefunction[php docs]. This will give you an array of strings of digits. You can convert each string to an integer by applyingintval[php docs] usingarray_map[php docs].