|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
An easy one for you...
if I have an array consisting of a number of domain names and prices like 'mydomain.com--11.99, mydomain.co.uk--5.99' etc... how can I split the array to make 1 new array with just the prices in? like '11.99,5.99' etc...
|
|
#2
|
|||
|
|||
|
RE: An easy one for you...
I'm a bit confused. You mention array, but then you represented these as strings. Are these actually arrays and you just separated each element by a comma? Let me know, I'm sure I can work up a solution for you.
|
|
#3
|
|||
|
|||
|
RE: An easy one for you...
If I understand what you mean, I assume each element of your array has something like the string "site.com--12.34" just do a cycle, calling each element of the array in each iteration and using the explode function to separate the values and put them inside a new array. Something like this (note I did not test this code and this is just an indication):
<? $size_of_array = 10; for ($i=0;$i<=$size_of_array;$i++){ $string = array[$i]; $AUX = explode (--,$string); price_only_array[$i] = $AUX[0];}?> the new_price_array array has only the prices inside. If you want another array with only the sites inside just add the line sites_only_array = AUX[1]; Or something like this ;-) hope this helps Rui Alves [php-db.com] |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > An easy one for you... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|