I am working on html form present in a php file as shown below in which I want to count the entered html input values.
Php/HTML Code:
<form method="post" style="display: inline-block; margin-left: auto; margin-right: auto; text-align: left;">
<div style ="display:flex; align-items: baseline;">
Articles (EN)
<input type="text" name="articles_id_en" style="width: 30%;height: 22px;" value="<?php if($data->{"articles_id_en"}<>''){echo $data->{"articles_id_en"};} ?>">
Articles (FR)
<input type="text" name="articles_id_fr" style="width: 30%;height: 22px;" value="<?php if($data->{"articles_id_fr"}<>''){echo $data->{"articles_id_fr"};} ?>"><br>
</div>
<div style ="display:flex; align-items: baseline;">
Articles Entered (EN)
<input type="text"style="width: 30%;height: 22px;" value="<?php $values = $_REQUEST['articles_id_en']; $delimiter = ','; $valuesCount = count(explode($delimiter, $values)); echo "Values Count: " . $valuesCount . "<br>" . PHP_EOL; ?>">
Articles (FR)
<input type="text" name="articles_id_fr" style="width: 30%;height: 22px;" value="<?php if($data->{"articles_id_fr"}<>''){echo $data->{"articles_id_fr"};} ?>"><br>
</div>
<div>
<button type="submit">Save</button>
</div>
</form>
On hitting save, its get saved in a JSON as shown below with their list of values entered. At this moment, I have entered 149968, 149939, 149883, 149877, 149876, 149847, 154303
values so in JSON its showing like this:
{"articles_id_en":"149968, 149939, 149883, 149877, 149876, 149847, 154303"}
Below is the section of the screenshot of the form belonging to the above html/php code:
After entering the values, it display like this:
Following is the html code on inspect:
<input type="text" name="articles_id_en" style="width: 30%;height: 22px;" value=" 14996, 14993, 14988, 14987, 14987, 14984, 15430">
Problem Statement:
I am wondering what php code I need to add so that I can get the count of input values entered.