i have some array like this
$post_array = array("title","content","price","dt","cat");
i want to make variable for all of them like this :
$title = $_GET['title'];
$content = $_GET['content'];
is that possible?
You can do simply using extract.
extract($_GET);
See doc.
If you want to make sure all of them exist, you can use a for loop this way:
foreach($post_array as $input) {
$$input = $_GET[$input];
}
This works because in php if say $var is 'title', $$var refers to the variable $title.
extract(array_intersect_key(array_flip($post_array), $_GET))