0
$pn=$_POST['pn'];
$ln=$_POST['ln'];
$logn=$_POST['logn'];
$wellno=$_POST['wellno'];  
for($i=0; $i<$chkcount; $i++) 
 {
  $msg=echo$wellno[$i].':'.echo$ln[$i].'/'.echo$pn[$i].'-'.echo$logn[$i];
  echo "<br>";
 }

I want $msg as a variable to send a message

1 Answer 1

1

You cannot use echo to concatenate variables. echo returns nothing. Actually, you have a PHP Parse Error : "syntax error, unexpected 'echo'".

$pn=$_POST['pn'];
$ln=$_POST['ln'];
$logn=$_POST['logn'];
$wellno=$_POST['wellno'];  
for($i=0; $i<$chkcount; $i++) 
{
    $msg = $wellno[$i].':'.$ln[$i].'/'.$pn[$i].'-'.$logn[$i];
    do_something_with($msg);
}

If you want to make an array, you could use [] operator to push the value into the array:

$msg=[];
for($i=0; $i<$chkcount; $i++) 
{
    $msg[] = $wellno[$i].':'.$ln[$i].'/'.$pn[$i].'-'.$logn[$i];
}
print_r($msg);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.