how to extract data from an array in PHP
Hello Stack Overflow i hope you are well today;
So i am using jQuer开发者_如何转开发y to append a form with more input fields; The Session is storing the data as an Array for the key: Children.
I would like to know show the user the data in that array how would this be done?
jQuery that adds the input fields (some pages previous)
$('.children-main-add').click(function(){
var attrName = $(this).attr('name');
var count = $(this).attr('count');
$(this).attr('count', (parseInt(count)+1))
var input = $('<input />');
input.attr('type','text')
input.attr('name',attrName+"["+count+"]" )
$('.children-main').append($('<li />').append(input));
$('#content li').removeClass('alt');
$('#content li:odd').addClass('alt');
$(this).val('Add Another Child');
})
The data from the session : Key: children / Value: Array
If i was not clear on something please let me know !
I thank you in advance for your help
if you want to show them as an continue string
use impode(',' , $_SESSION['children']);
Or
if(isset($_SESSION['children']) && is_array($_SESSION['children']))
{
foreach($_SESSION['children'] as $child)
{
echo $child."<br />";
// some other html
}
}
精彩评论