/    Sign up×
Community /Pin to ProfileBookmark

Never needed to create an array from with this method, and it should be doable. Can someone please assist?

I have a field in a database that is defined as a series of coordinates. FYi in the below example the item being recalled is defined as such:

[color=red]$prov[‘coords’]=’168,332,189,345,191,360,180,364,168,378,143,373,140,366,147,352,150,331′[/color]

I am recalling that from the database and trying to place it into an array at looks like this:

[code]
Array (
[0] => 168
[1] => 332
[2] => 189
[3] => 345
[4] => 191
[5] => 360
[6] => 180
[7] => 364
[8] => 168
[9] => 378
[10] => 143
[11] => 373
[12] => 140
[13] => 366
[14] => 147
[15] => 352
[16] => 150
[17] => 331
)
[/code]

I tried this, and it did not work properly:

[code=php]
$sql = mysql_query(“SELECT coords FROM `tbl` WHERE id=’1′”);
while ($prov = mysql_fetch_assoc ($prov_sql) ){
$values = array(($prov[‘coords’]));
}
[/code]

So, realizing what it was doing, I though perhaps I would put [color=red][i]print($prov[‘coords’])[/i][/color] inside the array function to list out the items I want in the array. That again did not produce the array correctly. Any Idea how to do it?

If you would like to see an example, let me know.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsMay 27.2005 — try[code=php]$values = explode(',', $prov['coords']);[/code]or[code=php]$values = preg_split("/s*,s*/", $prov['coords'], NULL, PREG_SPLIT_NO_EMPTY);[/code]
Copy linkTweet thisAlerts:
@ShmohelauthorMay 27.2005 — ahh.... much appreciated. thanks.
×

Success!

Help @Shmohel spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...