-1

I have to pass an associative array of email with the query string.

Please tell me how can I pass array with query string and how can I access the array element from there.

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
  • 2
    This is pretty basic stuff. Try watching a tutorial or something. For entertainment’s sake, you can access an array value by doing `$array[key]`. Where key is the index. This doesn't take into account multidimensional arrays. – Andrei Jul 01 '15 at 09:46

2 Answers2

0

You can use http_build_query() which also supports multi-dimensional arrays.

Simple example:

$a["one"] = "Bob";
$a["two"] = "Alice";
$a["three"] = "John";

echo http_build_query($a);

The above example will output:

one=Bob&two=Alice&three=John
kulaeff
  • 453
  • 3
  • 12
0

if you print_r($array_name)

is show array structer

  Array
  (
      [0] => Array
      (
          [id] => 007
          [name] => Abdulla 
          [online] => yes        
      )
  ) 

if you want access those

  echo $variables["array_name"][0]["name"]; //this will show the data

  foreach($variables["array_name"] as $item) 
  {
      $id = $item["id"];
      $name = $item["name"];
      $online = $item["online"];
  }     

read this Answer As well

To attch in email

  $to = '';//email address
  $subject = ''//subject here
  $message = 'Name : '.$name.'online : '.$online;    

  mail($to, $subject, $message)//send mail
Community
  • 1
  • 1
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85