hi guys, i need your help..any help would be appreciated...

im currently exploding a \$url and i need to explode the every 3 array from my first explode..

\$content = explode (\$url)
result
array[1]
array[2]
array[3]// need to explode
array[4]
array[5]
array[6]//need to explode
array[7]
array[8]
array[9]//need to explode
array[n]

i dont know how to do that in a loop because the array result in 40+
so i need to explode the every next 3 array..

thanks

Mike

If I understand what you're asking, try using a for loop like this:

``````for(\$i = 0; \$i < count(\$array); ++\$i)
{
if(\$i % 3 == 0)
explode(\$array);
}``````

The \$i % 3 will return the remainder of \$i divided by 3, and the remainder will be 0 every third element. I wasn't exactly sure if this is what you were trying to do; let me know if it helps.

What exactly are you trying to get out of the url? Perhaps there is a more efficient way to obtain it. Can you post and example url?

If I understand what you're asking, try using a for loop like this:

``````for(\$i = 0; \$i < count(\$array); ++\$i)
{
if(\$i % 3 == 0)
explode(\$array);
}``````

The \$i % 3 will return the remainder of \$i divided by 3, and the remainder will be 0 every third element. I wasn't exactly sure if this is what you were trying to do; let me know if it helps.

thanks man,
but i did a little revise
\$a = 0;
\$ii = 14;
while(\$a<=\$ii)
{
\$a++;
\$m = 3;
\$s = \$m*\$a;
\$cntry = explode ("<br>",\$url[\$s]);

but i have a new problem..
i got what i want but there are some parts of the url that does not match to the array i look for..
here's the code
if(\$count<=2)
{
\$street = "Street address not available";
\$city = \$cntry[0];
\$country1 = \$cntry[1];
\$country2 = explode ("</td>",\$country1);
}
elseif(\$count <=3)
{
\$street = \$cntry[0];
\$city = \$cntry[1];
\$country1 = \$cntry[2];
\$country2 = explode ("</td>",\$country1);
}
elseif(\$count>=7)
{
\$street = \$cntry[0];
\$city = \$cntry[1];
\$country1 = \$cntry[2];
\$country2 = explode ("</td>",\$country1);
}
else
{
\$street = \$cntry[0]." ".\$cntry[1];
\$city = \$cntry[2];
\$country1 = \$cntry[3];
\$country2 = explode ("</td>",\$country1);
}
\$sql = "INSERT INTO banco (SWIFT_BIC,Name,Street,City,Country) VALUES('".\$swift[0]."','".\$bname[0]."','".\$street."','".\$city."','".\$country2[0]."')";
mysql_query(\$sql,\$con);

my problem was the country.. the variable \$cntry is an address, i explode it by <br>.and it work..
DOUGLAS STREET ,//this to street
PORT MORESBY /// this to city
PAPUA NEW GUINEA //and this to country

but heres the problem
contain CITY AND COUNTRY ONLY which the array change..
contain street AND COUNTRY ONLY which the array change..

how can i get the correct array of country and city in that situation?