html - pass php variable value to javascript variable -


i trying pass values in variable of php retrieved .csv file javascript variable. variable of javascript null values. can 1 me value in java script variable. php tags

<?php     $i=0;     $handle = fopen("./uploads/csv_temp.csv", "r");     while (!feof($handle) ) {          $line_of_text = fgetcsv($handle, 1024, ",");         $json['json_'] = $line_of_text[0];         $a= $json['json_'];         // $a= $line_of_text[0];         // echo $json['json_'];          $json = json_encode ( $a, json_force_object );         echo $a;     } ?>  <html> <head></head> <body>     <script>     var abc= " <?php echo $a; ?> ";     </script> </body> </html> 

it looks need call json_encode on $json['json'] before pass $a, encode after have passed array $a

<?php     $i=0;     $handle = fopen("./uploads/csv_temp.csv", "r");     while (!feof($handle) ) {          $line_of_text = fgetcsv($handle, 1024, ",");         $json['json_'] = $line_of_text[0];         **$a= json_encode($json['json_']);**         echo $a;     } ?>  <html> <head></head> <body>     <script>     var abc= " <?php echo $a; ?> ";     </script> </body> </html> 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -