Home > database >  How to put a varrient inside an array in PHP
How to put a varrient inside an array in PHP

Time:11-02

I am trying to get data from mysql and try to put it in array loop.

that is what I want to reach my aim;

<?php
$carsa = '"Volvo","Deneme"';
$cars = array($carsa);
echo $cars[0];
?>

in that I get "Volvo","Deneme"

But I need to get Volvo

Where is my mistake. Thanks

CodePudding user response:

You need to use explode which will convert to array:

 $carsa = '"Volvo","Deneme"';
 $cars = explode(",",$carsa);
 echo trim($cars[0],'"');
  •  Tags:  
  • php
  • Related