Visa ett inlägg
Oläst 2008-03-09, 18:43 #1
KarlRoos KarlRoos är inte uppkopplad
Har WN som tidsfördriv
 
Reg.datum: Jul 2007
Inlägg: 1 416
KarlRoos KarlRoos är inte uppkopplad
Har WN som tidsfördriv
 
Reg.datum: Jul 2007
Inlägg: 1 416
Hej,
går det att loopa flera stycken arrays i PHP i samma loop?
Verkar inte funka med foreach.

Kod:
<?php
function make_list($url,$title,$display)
{
	$return = '';
	foreach($url as $url)
	{
 *$return = $return . $url;
 *foreach($title as $title)
 *{
 *	$return = $return . $title;
 *	foreach($display as $display)
 *	{
 * *$return = $return . $display;
 *	}
 *}
	}
	return $return;
}

$url = array();
$title = array();
$display = array();

$url[0] = 'url0';
$title[0] = 'title0';
$display[0] = 'display0';
$url[1] = 'url1';
$title[1] = 'title1';
$display[1] = 'display1';

echo make_list($url,$title,$display);
?>
Skriver ut...
Citat:
Warning: Invalid argument supplied for foreach() in /home/web28141/domains/roosstudios.com/public_html/test.php on line 11

Warning: Invalid argument supplied for foreach() in /home/web28141/domains/roosstudios.com/public_html/test.php on line 8
url0title0display0display1title1url1
Det funkar iofs, men gillar inte när jag får massa errors <_<
Och jag tänker inte trycka in ini_set('display_errors', '0'); utan jag vill ha "riktig" kod.

Tack
KarlRoos är inte uppkopplad   Svara med citatSvara med citat