studiosx Posted March 21, 2014 Share Posted March 21, 2014 I want to export videos, thumbs, duration, etc from my website into a xml format. I got this error:Invalid argument supplied for foreach() $output .= ' <clips>'; if (!is_array( $vids )) { $vids = array( ); foreach ($imgs as $img) { $img = explode( '.', $img ); $vids[] = '0' . $img[0] . '.flv'; } } @sort( $vids ); @sort( $imgs ); $i = 38; foreach ($vids as $v) { $output .= ' <clip>'; $output .= ' <duration>' . $duration . '</duration>'; $output .= ' <width>' . $width . '</width>'; $output .= ' <height>' . $height . '</height>'; $output .= ' <flv>' . $v . '</flv>'; $output .= ' <screens> <screen>' . trim( $imgs[$i] ) . '</screen> </screens>'; $output .= ' </clip>'; ++$i; } $output .= ' </clips>'; Thank you! Link to comment https://forums.phpfreaks.com/topic/287151-foreach-error/ Share on other sites More sharing options...
gristoi Posted March 21, 2014 Share Posted March 21, 2014 chances are $imgs is not an array Link to comment https://forums.phpfreaks.com/topic/287151-foreach-error/#findComment-1473439 Share on other sites More sharing options...
studiosx Posted March 21, 2014 Author Share Posted March 21, 2014 What is that mean? I'm a beginner. Link to comment https://forums.phpfreaks.com/topic/287151-foreach-error/#findComment-1473440 Share on other sites More sharing options...
jairathnem Posted March 21, 2014 Share Posted March 21, 2014 how is value stored to $imgs? do a var_dump($imgs) before the foreach loop and check if it holds any data. Link to comment https://forums.phpfreaks.com/topic/287151-foreach-error/#findComment-1473452 Share on other sites More sharing options...
studiosx Posted March 21, 2014 Author Share Posted March 21, 2014 XML Parsing Error: syntax error NULL ^ Link to comment https://forums.phpfreaks.com/topic/287151-foreach-error/#findComment-1473455 Share on other sites More sharing options...
jairathnem Posted March 21, 2014 Share Posted March 21, 2014 there is your problem. $imgs isn't holding any data. check how it is generated. Link to comment https://forums.phpfreaks.com/topic/287151-foreach-error/#findComment-1473459 Share on other sites More sharing options...
gristoi Posted March 21, 2014 Share Posted March 21, 2014 http://docs.php.net/manual/en/language.types.array.php Link to comment https://forums.phpfreaks.com/topic/287151-foreach-error/#findComment-1473460 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.