我想将PHP变量发送到模态但需要获取它也是一个php变量

I have more then 2 forms like

<body>
<form id="form1">
    <input type="hidden" name="var1" value="value1">
    <input type="submit" name="button1" data-toggle='modal' data-target='#myModal'>
</form>
<form id="form2">
    <input type="hidden" name="var2" value="value2">
    <input type="submit" name="button2" data-toggle='modal' data-target='#myModal'>
</form>
<form id="form3">
    <input type="hidden" name="var3" value="value3">
    <input type="submit" name="button3" data-toggle='modal' data-target='#myModal'>
</form>
</body>

And I try to send 1 value to same modal and try to use variable

I need to know which button send which variable

<div class="modal fade" id="userEdit">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
            <?php
            // I need to know which button send which variable
            $var = $_POST["var1"];
            echo ($var);
            ?>  
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                <button type="submit" class="btn btn-primary"  name="button1">Submit</button>
            </form>
            </div>
        </div>
    </div>
</div>

How can I make it. Or do you have any advice how I do that? I try many times with Ajax and not success. can you sen me a working example? Thanks

Try this in your modal:

for($i=1;$i<=10;$i++) {
    $var = ''; 
    if(isset($_POST["var".$i])) {
        echo 'Horray, its var number '.$i; 
        $var = $_POST["var".$i];
        break;
    }
    echo ($var);
}