0

i need to show the array values separate

$ids = array(12,13,14);
$ids1 = explode(",", $ids);
echo $ids1;

if i run this it shows array

Edited by malatamil: h

2
Contributors
2
Replies
10
Views
3 Years
Discussion Span
Last Post by malatamil
1
$ids = array(12,13,14);
foreach($ids as $id) echo $id;

No need to explode. explode() cuts a string into an array. Or...

$ids = array(12,13,14);
echo $ids[0];
echo $ids[1];
echo $ids[02];
0

thanks it works.and one more question if i want to upload array string values into single field how..
i used to upload like

$cityid = trim(ucwords(strtolower(mysql_real_escape_string($_POST['city']))));
            $num=count($_POST["place"]);
            /*foreach($_POST["place"] as $i=>$value) 
            {
                $value=$_POST["place"][$i];*/
                $ids = array();
                foreach($_POST['place'] as $val)
                {
                $ids[] = (int) $val;
                }
                $ids = implode(',', $ids);
                $sql3 = mysql_query("INSERT INTO `city_place`(`state_id`,`city_id`,`spaid`) VALUES ('$cityid','$ids',$lid)");

instead of id i want to stores string

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.