What is the right way for doing this?
It gives me an error:
$lingue = array('IT','EN','FR');
$item = new stdClass();
$item->IDCat = 1;
foreach($lingue as $l){
$item->Desc_{$l} = trim(addslashes($_POST['Desc_'.$l]);
}
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.
The dynamic accessor must be enclosed with curly braces and you’r lacking a
)at the end of thetrim()call.Just to highlight the difference between
$item->{'Desc_'.$l} = ...and$item->Desc_{$l} = ...:while
This is actually the same as
Seems to be an imprudence in the parser.