Reputation: 93
Hello i have fallowing post input data
i am trying to update localize file which is json format it has 524 Lines, and output is success
{
"loading_js_content":"Loading Javascript Content...",
"offical_site":"Official Site",
"Online_users":"Online Users",
......
.....
......
and go on
}
html
<form method="POST" action="" id="lang_file" class="FormBlock">
<table class="ranktable">
<tr class="head" >
<td colspan="2" id="boxTitle">Edit/Update <?php echo $LangName; ?> Values</td>
</tr>
<tr class="head">
<td>#</td>
<td>Key</td>
<td>Value</td>
</tr>
<?php
$i = 0;
foreach($LangData as $key => $value):
$i++;
$class = ($i%2==0) ? 'alt1' : 'alt2';
?>
<tr class="<?php echo $class; ?>">
<td><?php echo $i; ?></td>
<td style="text-align:left">
<input type="text" name="lang_key[]" class="formatted" value="<?php echo $key; ?>" style="width:150px;" />
</td>
<td style="text-align:left">
<input type="text" name="lang_val[]" class="formatted" value="<?php echo $value; ?>" style="width:380px;" />
</td>
</tr>
<?php endforeach; ?>
</table>
The problem is when getting post. Count $_POST['lang_key'] is 500 lines instate of 524.24 line is missing affter line 500.
How can i write it to file back as same format ? i have fallowing code as far as i can do
foreach( $_POST['lang_key'] as $lang_key => $key)
{
$data[] = $key;
}
foreach( $_POST['lang_value'] as $lang_value => $val)
{
$data[] = $val;
}
file_put_contents(BASE_DIRECTORY.'test.json',json_encode($data,JSON_PRETTY_PRINT));
Upvotes: 0
Views: 105
Reputation: 93
I got the solution after some search. The problem is comes from max_input_vars in php.ini
: its default is 1000
. So when I try to post 500 -> lang_key and 500 -> lang_value
it's oversize it.
So the solution is change php.ini -> max_input_vars
to bigger value and no more issues.
Upvotes: 1
Reputation: 781235
You need to use the lang_key
parameters as the keys in the associative array, and lang_value
as the corresponding values.
foreach ($_POST['lang_key'] as $index => $key) {
$data[$key] = $_POST['lang_value'][$index];
}
I don't know why you're only getting 500 inputs, though.
Upvotes: 1