Connecting Tech Pros Worldwide Forums | Help | Site Map

Fetch array values

Member
 
Join Date: Feb 2008
Posts: 65
#1: Apr 4 '08
Hi friends,

I'm having a table which stores id as comma separated in string datatype.
I want to fetch each of the value in a row in the form of array such as follows:

table:
sid name
2,3,5,7,9... Apple
19,37,46,1... Orange

What i need is,
array[0]=2 array[1]=3......

each comma separated value should be in separate array.

How can i do this either in php script or in mysql?
I tried it by explode() function of php. But didn't work properly...
Please, help me out.

Thanx n Regards
Yas....
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#2: Apr 4 '08

re: Fetch array values


You are doing PHP programming now for quite some time. And all you have to do is store each exploded entry in another entry to an array.[php]<?php
$string='2,3,5,7,9';
$a_arr=explode(',', $string);
$b_arr=array();
foreach($a_arr as $val)
$b_arr[]=array($val);
?>[/php]Ronald
Reply