Last active
November 5, 2020 07:20
-
-
Save YuvrajKhavad/6af9624f39ebdbddd575e9bc33821319 to your computer and use it in GitHub Desktop.
Genreate dynamic php variable using foreach from array of form serialize data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$selected_data = $_POST['selected_data']; | |
print_r($selected_data); | |
/* | |
// array formate | |
Array | |
( | |
[0] => Array | |
( | |
[name] => authorname | |
[value] => 201 | |
) | |
[1] => Array | |
( | |
[name] => posttags | |
[value] => Tag5 | |
) | |
) | |
*/ | |
if(is_array($selected_data)) | |
{ | |
foreach($selected_data as $data) | |
{ | |
${$data['name']} = $data['value']; | |
} | |
} | |
echo $authorname; | |
echo "</br>"; | |
echo $posttags; | |
// output | |
201</br>Tag5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment