Invalid argument supplied for foreach()
adonis
-
le père -
le père -
Bonjour,
J'ai cette erreur qui apparait de nombreuses fois :
Warning: Invalid argument supplied for foreach() in /home/www/components/sef_ext.php on line 148
Le bout de code concerné est:
foreach ($ext_strip as $value) {
$string = ereg_replace(urlencode($value), $value, $string);
}
if ($ext_lower) {
$string = strtolower($string);
}
return $string;
}
J'arrive pas a remedier a ca, faut dire que je debute donc un petit coup de main m'aiderais bien.
Merci d'avance
J'ai cette erreur qui apparait de nombreuses fois :
Warning: Invalid argument supplied for foreach() in /home/www/components/sef_ext.php on line 148
Le bout de code concerné est:
foreach ($ext_strip as $value) {
$string = ereg_replace(urlencode($value), $value, $string);
}
if ($ext_lower) {
$string = strtolower($string);
}
return $string;
}
J'arrive pas a remedier a ca, faut dire que je debute donc un petit coup de main m'aiderais bien.
Merci d'avance
Configuration: Windows Vista Firefox 3.5.5
A voir également:
- Invalid argument supplied for foreach()
- Downloader for pc - Télécharger - Téléchargement & Transfert
- Copytrans heic for windows - Télécharger - Visionnage & Diaporama
- Idm for mac - Télécharger - Téléchargement & Transfert
- Lame for audacity - Télécharger - Création musicale
- Instagram for pc - Télécharger - Divers Communication
4 réponses
Bonjour
Foreach a besoin d'un tableau.
Ton message signifie que $ext_strip n'est pas un tableau.
Il faudrait que tu montres d'où vient ta variable $ext_strip
Foreach a besoin d'un tableau.
Ton message signifie que $ext_strip n'est pas un tableau.
Il faudrait que tu montres d'où vient ta variable $ext_strip
Voila le code en entier:
<?php
class sef_puarcade {
function create ($string) {
global $database;
$sefstring = "";
$string = str_replace( '&', '&', $string );
if (eregi("&fid=",$string)) {
$temp = split("&fid=", $string);
$temp = split("&", $temp[1]);
$fid = $temp[0];
if ($fid !=9999 && $fid !=9998 && $fid !=9997)
{
$query = "SELECT id, name FROM #__puarcade_folders" ;
$query .= "\n WHERE id=".$fid;
$database->setQuery( $query );
$result = $database->loadObjectList();
$abfrage = $result[0];
if (empty($result)){
$sefstring .= $temp[0]."";
} else {
$sefstring .= encode_puarcade($abfrage->name)."/";
}
}
elseif ($fid == 9999)
{
$sefstring .= "my-favorites/";
}
elseif ($fid == 9998)
{
$sefstring .= "newest-games/";
}
elseif ($fid == 9997)
{
$sefstring .= "popular-games/";
}
}
if (eregi("&gid=",$string)) {
$temp = split("&gid=", $string);
$temp = split("&", $temp[1]);
$gid = $temp[0];
$query = "SELECT id, title FROM #__puarcade_games" ;
$query .= "\n WHERE id=".$gid;
$database->setQuery( $query );
$result = $database->loadObjectList();
$abfrage = $result[0];
if (empty($result)){
$sefstring .= $temp[0]."";
} else {
$sefstring .= encode_puarcade($abfrage->title)."/";
}
}
if (eregi("&arcade=",$string)) {
$temp = split("&arcade=", $string);
$temp = split("&", $temp[1]);
$arcade = $temp[0];
if ($arcade == "leaderboard")
{
$sefstring .= "leaderboard/";
} else {
$sefstring .= $temp[0]."/";
}
}
if (eregi("&gname=",$string)) {
$temp = split("&gname=", $string);
$temp = split("&", $temp[1]);
$sefstring .= $temp[0]."/";
}
return $sefstring;
}
function revert ($url_array, $pos) {
global $fid, $gid, $arcade, $gname;
$QUERY_STRING = "";
if (isset($url_array[$pos+2]) && $url_array[$pos+2]!="") {
$fid = $url_array[$pos+3];
$_GET['fid'] = $fid;
$_REQUEST['fid'] = $fid;
$QUERY_STRING .= "&fid=$fid";
}
if (isset($url_array[$pos+2]) && $url_array[$pos+2]!="") {
$gid = $url_array[$pos+3];
$_GET['gid'] = $gid;
$_REQUEST['gid'] = $gid;
$QUERY_STRING .= "&gid=$gid";
}
if (isset($url_array[$pos+2]) && $url_array[$pos+2]!="") {
$arcade = $url_array[$pos+2];
$_GET['arcade'] = $arcade;
$_REQUEST['arcade'] = $arcade;
$QUERY_STRING .= "&arcade=$arcade";
}
if (isset($url_array[$pos+3]) && $url_array[$pos+3]!="") {
$gname = $url_array[$pos+3];
$_GET['gname'] = $gname;
$_REQUEST['gname'] = $gname;
$QUERY_STRING .= "&gname=$gname";
}
return $QUERY_STRING;
}
}
function encode_puarcade($string) {
global $sefConfig, $sufix, $lowercase,$url_exception;
if (empty($sefConfig)) {
$ext_suffix = $sufix;
$ext_space = "-" ;
$ext_lower = $lowercase;
$ext_strip = $url_exception;
} else {
$ext_suffix = $sefConfig->encode_page_suffix;
$ext_space = $sefConfig->encode_space_char;
$ext_lower = $sefConfig->encode_lowercase;
$ext_strip = array($sefConfig->encode_strip_chars);
}
$string = urlencode($string);
$string = eregi_replace("%11", $ext_space, $string);
$string = eregi_replace("\+", $ext_space, $string);
$string = eregi_replace("re%3A", "re", $string);
$string = eregi_replace("%C4", "Ae", $string);
$string = eregi_replace("%D6", "Oe", $string);
$string = eregi_replace("%DC", "Ue", $string);
$string = eregi_replace("%E4", "ae", $string);
$string = eregi_replace("%F6", "oe", $string);
$string = eregi_replace("%FC", "ue", $string);
$string = eregi_replace("%df", "ss", $string);
$string = eregi_replace("%26", "", $string);
$string = eregi_replace("%b4", "", $string);
$string = eregi_replace("auml%3b", "ae", $string);
$string = eregi_replace("%2F", "-", $string);
$string = eregi_replace("%22", "", $string);
$string = eregi_replace("%5C", "", $string);
$string = eregi_replace("%3A", "", $string);
$string = eregi_replace("%2F", "%10", $string);
$string = eregi_replace("%2C", "", $string);
foreach ($ext_strip as $value) {
$string = ereg_replace(urlencode($value), $value, $string);
}
if ($ext_lower) {
$string = strtolower($string);
}
return $string;
}
?>
Merci d'avance
<?php
class sef_puarcade {
function create ($string) {
global $database;
$sefstring = "";
$string = str_replace( '&', '&', $string );
if (eregi("&fid=",$string)) {
$temp = split("&fid=", $string);
$temp = split("&", $temp[1]);
$fid = $temp[0];
if ($fid !=9999 && $fid !=9998 && $fid !=9997)
{
$query = "SELECT id, name FROM #__puarcade_folders" ;
$query .= "\n WHERE id=".$fid;
$database->setQuery( $query );
$result = $database->loadObjectList();
$abfrage = $result[0];
if (empty($result)){
$sefstring .= $temp[0]."";
} else {
$sefstring .= encode_puarcade($abfrage->name)."/";
}
}
elseif ($fid == 9999)
{
$sefstring .= "my-favorites/";
}
elseif ($fid == 9998)
{
$sefstring .= "newest-games/";
}
elseif ($fid == 9997)
{
$sefstring .= "popular-games/";
}
}
if (eregi("&gid=",$string)) {
$temp = split("&gid=", $string);
$temp = split("&", $temp[1]);
$gid = $temp[0];
$query = "SELECT id, title FROM #__puarcade_games" ;
$query .= "\n WHERE id=".$gid;
$database->setQuery( $query );
$result = $database->loadObjectList();
$abfrage = $result[0];
if (empty($result)){
$sefstring .= $temp[0]."";
} else {
$sefstring .= encode_puarcade($abfrage->title)."/";
}
}
if (eregi("&arcade=",$string)) {
$temp = split("&arcade=", $string);
$temp = split("&", $temp[1]);
$arcade = $temp[0];
if ($arcade == "leaderboard")
{
$sefstring .= "leaderboard/";
} else {
$sefstring .= $temp[0]."/";
}
}
if (eregi("&gname=",$string)) {
$temp = split("&gname=", $string);
$temp = split("&", $temp[1]);
$sefstring .= $temp[0]."/";
}
return $sefstring;
}
function revert ($url_array, $pos) {
global $fid, $gid, $arcade, $gname;
$QUERY_STRING = "";
if (isset($url_array[$pos+2]) && $url_array[$pos+2]!="") {
$fid = $url_array[$pos+3];
$_GET['fid'] = $fid;
$_REQUEST['fid'] = $fid;
$QUERY_STRING .= "&fid=$fid";
}
if (isset($url_array[$pos+2]) && $url_array[$pos+2]!="") {
$gid = $url_array[$pos+3];
$_GET['gid'] = $gid;
$_REQUEST['gid'] = $gid;
$QUERY_STRING .= "&gid=$gid";
}
if (isset($url_array[$pos+2]) && $url_array[$pos+2]!="") {
$arcade = $url_array[$pos+2];
$_GET['arcade'] = $arcade;
$_REQUEST['arcade'] = $arcade;
$QUERY_STRING .= "&arcade=$arcade";
}
if (isset($url_array[$pos+3]) && $url_array[$pos+3]!="") {
$gname = $url_array[$pos+3];
$_GET['gname'] = $gname;
$_REQUEST['gname'] = $gname;
$QUERY_STRING .= "&gname=$gname";
}
return $QUERY_STRING;
}
}
function encode_puarcade($string) {
global $sefConfig, $sufix, $lowercase,$url_exception;
if (empty($sefConfig)) {
$ext_suffix = $sufix;
$ext_space = "-" ;
$ext_lower = $lowercase;
$ext_strip = $url_exception;
} else {
$ext_suffix = $sefConfig->encode_page_suffix;
$ext_space = $sefConfig->encode_space_char;
$ext_lower = $sefConfig->encode_lowercase;
$ext_strip = array($sefConfig->encode_strip_chars);
}
$string = urlencode($string);
$string = eregi_replace("%11", $ext_space, $string);
$string = eregi_replace("\+", $ext_space, $string);
$string = eregi_replace("re%3A", "re", $string);
$string = eregi_replace("%C4", "Ae", $string);
$string = eregi_replace("%D6", "Oe", $string);
$string = eregi_replace("%DC", "Ue", $string);
$string = eregi_replace("%E4", "ae", $string);
$string = eregi_replace("%F6", "oe", $string);
$string = eregi_replace("%FC", "ue", $string);
$string = eregi_replace("%df", "ss", $string);
$string = eregi_replace("%26", "", $string);
$string = eregi_replace("%b4", "", $string);
$string = eregi_replace("auml%3b", "ae", $string);
$string = eregi_replace("%2F", "-", $string);
$string = eregi_replace("%22", "", $string);
$string = eregi_replace("%5C", "", $string);
$string = eregi_replace("%3A", "", $string);
$string = eregi_replace("%2F", "%10", $string);
$string = eregi_replace("%2C", "", $string);
foreach ($ext_strip as $value) {
$string = ereg_replace(urlencode($value), $value, $string);
}
if ($ext_lower) {
$string = strtolower($string);
}
return $string;
}
?>
Merci d'avance
Ok vraiment pas simple
Mais si, c'est très simple au contraire de vérifier si une variable a bien la valeur qu'on attend ou pas. Où vois-tu un problème ?
j'ai pas la possibilité dans le fichier .htaccess d'empêcher l'apparition de ces avertissements Et c'est très bien comme ça. Sur ta voiture, quand tu as un voyant rouge qui s'allume, tu enlèves l'ampoule pour ne plus le voir ? Les avertissements montrent des erreurs de programmation et, à moins que tu en comprennes exactement la cause et que tu n'y puisses vraiment rien, ils demandent une correction.
Mais si, c'est très simple au contraire de vérifier si une variable a bien la valeur qu'on attend ou pas. Où vois-tu un problème ?
j'ai pas la possibilité dans le fichier .htaccess d'empêcher l'apparition de ces avertissements Et c'est très bien comme ça. Sur ta voiture, quand tu as un voyant rouge qui s'allume, tu enlèves l'ampoule pour ne plus le voir ? Les avertissements montrent des erreurs de programmation et, à moins que tu en comprennes exactement la cause et que tu n'y puisses vraiment rien, ils demandent une correction.