Home > Enterprise >  Add single quotes when encoding data in php
Add single quotes when encoding data in php

Time:12-03

I have a array :

$arr = ['name', 'age', 'address'];
$impString = implode(',',$arr); 
// result : "name','age','address"

The result I want: "'name','age','address'"

Help me please.

CodePudding user response:

$arr = ['name', 'age', 'address'];
echo "\"'".implode("','", $arr)."'\"";

CodePudding user response:

you can try this

<?php
    
$arr = ["name", "age", "address"];
$impString = "'".implode("','",$arr)."'";
echo $impString;
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

  •  Tags:  
  • php
  • Related