$i = array(1,2,3,4,5,6,7,8,9,0);
$k =0;
foreach($i as $j)
{
$k = $k+1;
}
for($n=0; $n<$k; $n++)
{
echo $i[$n];
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have an array
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]
How can i pass this array to ajax and get it from controller?
$(document).on('click', '#print', function(){
var code = $(this).attr('data-code');
$.ajax({
type: 'GET',
url: 'print',
data: {code: code,option: array here},
dataType: 'html',
success: function (html) {
w = window.open(window.location.href,"_blank");
w.document.open();
w.document.write(html);
w.document.close();
},
error: function (data) {
console.log('Error:', data);
}
});
});
In controller
Input::get('option');
Please or to participate in this conversation.