Jump to content

Array...


lordphate

Recommended Posts

okay what i'm trying to do is make something from the mysql database work as a image

 

function contest_extract_answers($answers_code){

 

$answers = explode("|",trim($answers_code,"|"));

array_unshift($answers,"");

unset($answers[0]);

 

return $answers;

 

}//contest_extract_answers

 

$answers will be a path to the pictures minus the domain.com/photos

 

So i tried making it

 

function contest_extract_answers($answers_code){

 

$answers = explode("|",trim($answers_code,"|"));

array_unshift($answers,"");

unset($answers[0]);

 

return "<img src='http://www.domain.com/photos/".$answers.">";

 

}//contest_extract_answers

 

but this causes the "photo" to be http://www.domain.com/photos/Array

 

How do i turn the "Array" into  the /path/to/photo.jpg

Link to comment
https://forums.phpfreaks.com/topic/56501-array/
Share on other sites

try

function contest_extract_answers($answers_code){

   $answers = explode("|",trim($answers_code,"|"));
   array_unshift($answers,"");
   unset($answers[0]);
   $out ='';
   foreach($answera as $v) {$out .= <img src='http://www.domain.com/photos/".$v.">";};
   //return "<img src='http://www.domain.com/photos/".$answers.">";
   return $out;
}

Link to comment
https://forums.phpfreaks.com/topic/56501-array/#findComment-279061
Share on other sites

Warning: Invalid argument supplied for foreach() in C:\wamp\www\paul\modules\contest.php on line 259

Warning: array_keys() [function.array-keys]: The first argument should be an array in C:\wamp\www\paul\modules\contest.php on line 61

Warning: Invalid argument supplied for foreach() in C:\wamp\www\paul\modules\contest.php on line 100

 

  58              $card["author"] = $GLOBALS["Network"]->card($res["mem_id"]);
59		$card["question"] = $res["question"];
60		$card["answers"] = contest_extract_answers($res["answers"]);
61		$card["stats"] = contest_stats($res["con_id"],array_keys($card["answers"]));
62		$card["approved"] = $res["approved"];

 

 

99	$stats["votes"] = array();
100	foreach($answers as $a){
101		$stats["votes"][$a] = @round($votes[$a]/$stats["total"],2) * 100;
102	}//foreach

 

258      $out ='';
259      foreach($answera as $v) {$out .= "<img src='http://www.paul.com/photos/".$v."'>";};
  260      //return "<img src='http://www.domain.com/photos/".$answers.">";
   261     return $out;

Link to comment
https://forums.phpfreaks.com/topic/56501-array/#findComment-279065
Share on other sites

Yeah i noticed that, but i'm still getting

 

 

Warning: array_keys() [function.array-keys]: The first argument should be an array in C:\wamp\www\paul\modules\contest.php on line 61

 

Warning: Invalid argument supplied for foreach() in C:\wamp\www\paul\modules\contest.php on line 100

 

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\paul\modules\contest.php:61) in C:\wamp\www\paul\functions\build_functions.php on line 120

 

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\paul\modules\contest.php:61) in C:\wamp\www\paul\functions\build_functions.php on line 121

 

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\paul\modules\contest.php:61) in C:\wamp\www\paul\functions\build_functions.php on line 122

 

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\paul\modules\contest.php:61) in C:\wamp\www\paul\functions\build_functions.php on line 123

Link to comment
https://forums.phpfreaks.com/topic/56501-array/#findComment-279071
Share on other sites

example only.

 

always valadate ok.

<?php

$pic_array=array("http://www.google.co.uk/intl/en_uk/images/logo.gif");

$x=implode(' ',$pic_array);

if(eregi("^(http://www)\.[a-z0-9\_\-]{1,50}\.[a-z]{0,3}\.[a-z]{0,3}\/[a-z\_-]{0,50}\/[a-z\_-]{0,50}\/[a-z\_-]{0,50}\/[a-z]{0,50}\.(jpg|gif|png)",$x)){

echo"<img src'$x'></img>";

}else{

echo "sorry pic does not exist";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/56501-array/#findComment-279086
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.