/    Sign up×
Community /Pin to ProfileBookmark

I have the following array ($stores):

Array ( [00246] => Array ( [name] => [addr1] => 337 West Chocolate Avenue [city] => Hershey [state] => PA [zip] => 17033 [phone_fe] => (717) 533-2941 [phone_ph] => (717) 533-2941 [phone_phf] => (717) 534-0692 [store_date_open] => [store_date_relo] => [store_date_reopen] => ) [04287] => Array ( [name] => [addr1] => 360 East Main Street [city] => Middletown [state] => PA [zip] => 17057 [phone_fe] => (717) 944-0262 [phone_ph] => (717) 944-0262 [phone_phf] => (717) 944-7602 [store_date_open] => [store_date_relo] => [store_date_reopen] => ) [04260] => Array ( [name] => [addr1] => 4299 Union Deposit Road [city] => Harrisburg [state] => PA [zip] => 17111 [phone_fe] => (717) 564-6750 [phone_ph] => (717) 564-6750 [phone_phf] => (717) 564-4839 [store_date_open] => [store_date_relo] => [store_date_reopen] => ) [01662] => Array ( [name] => [addr1] => 700 East Main Street [city] => Palmyra [state] => PA [zip] => 17078 [phone_fe] => (717) 838-8878 [phone_ph] => (717) 838-8878 [phone_phf] => (717) 832-3499 [store_date_open] => [store_date_relo] => [store_date_reopen] => ) [04284] => Array ( [name] => [addr1] => 3601 Walnut Street [city] => Harrisburg [state] => PA [zip] => 17109 [phone_fe] => (717) 545-8183 [phone_ph] => (717) 545-8183 [phone_phf] => (717) 545-8492 [store_date_open] => [store_date_relo] => [store_date_reopen] => ) [00866] => Array ( [name] => [addr1] => 501 South 29th Street [city] => Harrisburg [state] => PA [zip] => 17104 [phone_fe] => (717) 233-5344 [phone_ph] => (717) 233-5344 [phone_phf] => (717) 236-5095 [store_date_open] => [store_date_relo] => [store_date_reopen] => ) [01304] => Array ( [name] => [addr1] => 124 South Front Street [city] => Steelton [state] => PA [zip] => 17113 [phone_fe] => (717) 939-7235 [phone_ph] => (717) 939-7235 [phone_phf] => (717) 985-0674 [store_date_open] => [store_date_relo] => [store_date_reopen] => ) [03608] => Array ( [name] => [addr1] => 1941 Derry Street [city] => Harrisburg [state] => PA [zip] => 17104 [phone_fe] => (717) 234-3350 [phone_ph] => (717) 234-3350 [phone_phf] => (717) 236-4371 [store_date_open] => [store_date_relo] => [store_date_reopen] => ) [00418] => Array ( [name] => [addr1] => 105 Old York Road [city] => New Cumberland [state] => PA [zip] => 17070 [phone_fe] => (717) 774-0261 [phone_ph] => (717) 774-0261 [phone_phf] => (717) 774-2810 [store_date_open] => [store_date_relo] => [store_date_reopen] => )

How do I pull out just the store number (00246, 04287, etc) and put it in it’s own array like $stornum = array(values)?

Thanks!!

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@pyroNov 18.2003 — Is this psedocode, or have you made a custom function named Array?
Copy linkTweet thisAlerts:
@jrthor2authorNov 18.2003 — no, this is the result of $stores

print_r($stores)
Copy linkTweet thisAlerts:
@pyroNov 18.2003 — This example should get you started:

[code=php]<?PHP
$array = array("a" => array("1", "2", "3"), "b" => array ("4", "5", "6"));

foreach ($array as $key => $val) {
$newarray[] = $key;
}

# $newarray is the array of all the top level array values

?> [/code]
×

Success!

Help @jrthor2 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.28,
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,
)...