echo 수 더하기 질문입니다.
본문
안녕하세요 밑에 http://도메인(번호1부터10).com/test.php 에 숫자가 들어있는데요
그냥 아래소스로 하면 숫자 10개만 출력 됩니다. 그 숫자를 더한값(합한값) 으로 나타낼수 있나요? 도와주세요^^
그냥 아래소스로 하면 숫자 10개만 출력 됩니다. 그 숫자를 더한값(합한값) 으로 나타낼수 있나요? 도와주세요^^
<?
$_conf__url = array();
$_conf__url[] = "http://도메인1.com/test.php" ;
$_conf__url[] = "http://도메인2.com/test.php" ;
$_conf__url[] = "http://도메인3.com/test.php" ;
$_conf__url[] = "http://도메인4.com/test.php" ;
$_conf__url[] = "http://도메인5.com/test.php" ;
$_conf__url[] = "http://도메인6.com/test.php" ;
$_conf__url[] = "http://도메인7.com/test.php" ;
$_conf__url[] = "http://도메인8.com/test.php" ;
$_conf__url[] = "http://도메인9.com/test.php" ;
$_conf__url[] = "http://도메인10.com/test.php" ;
$cnt=count($_conf__url);
$resultset=array();
for( $i = 0; $i < $cnt; $i++ ){
$url = $_conf__url[$i];
ini_set("allow_url_fopen", 1);
echo $resultset[$url] = file_get_contents($url);
}
?>
$_conf__url = array();
$_conf__url[] = "http://도메인1.com/test.php" ;
$_conf__url[] = "http://도메인2.com/test.php" ;
$_conf__url[] = "http://도메인3.com/test.php" ;
$_conf__url[] = "http://도메인4.com/test.php" ;
$_conf__url[] = "http://도메인5.com/test.php" ;
$_conf__url[] = "http://도메인6.com/test.php" ;
$_conf__url[] = "http://도메인7.com/test.php" ;
$_conf__url[] = "http://도메인8.com/test.php" ;
$_conf__url[] = "http://도메인9.com/test.php" ;
$_conf__url[] = "http://도메인10.com/test.php" ;
$cnt=count($_conf__url);
$resultset=array();
for( $i = 0; $i < $cnt; $i++ ){
$url = $_conf__url[$i];
ini_set("allow_url_fopen", 1);
echo $resultset[$url] = file_get_contents($url);
}
?>
답변 7
이렇게 하고 싶으신거에요?
<?php
$thisArray = array(1,2,3,4,5,6,7,8,9,10);
foreach($thisArray AS $item => $val){
$vals = $vals+$val;
echo("배열번호 : ".$item." 배열값 : ".$val." ---- Is this Domain? http://www.domain".$vals.".com/test.php<br />");
}
?>
뭘 원하시는거죠 ㄷㄷㄷ
주소를 출력하기를 원하시는건가요??
그 숫자를 더한값(합한값) 으로 나타낼수 있나요?
이게 뭔말인가요?
질문을 좀 더 상세히 그리고 요점을 집어서 질문해주세요
이게 뭔말인가요?
질문을 좀 더 상세히 그리고 요점을 집어서 질문해주세요
다시 질문하겠습니다.ㅜㅜ
<?
$_conf__url = array();
$_conf__url[] = "http://도메인1.com/test.php" ;
$_conf__url[] = "http://도메인2.com/test.php" ;
$_conf__url[] = "http://도메인3.com/test.php" ;
$_conf__url[] = "http://도메인4.com/test.php" ;
$_conf__url[] = "http://도메인5.com/test.php" ;
$_conf__url[] = "http://도메인6.com/test.php" ;
$_conf__url[] = "http://도메인7.com/test.php" ;
$_conf__url[] = "http://도메인8.com/test.php" ;
$_conf__url[] = "http://도메인9.com/test.php" ;
$_conf__url[] = "http://도메인10.com/test.php" ;
$cnt=count($_conf__url);
$resultset=array();
for( $i = 0; $i < $cnt; $i++ ){
$url = $_conf__url[$i];
ini_set("allow_url_fopen", 1);
echo $resultset[$url] = file_get_contents($url);
}
?>
-------------------------------------출력화면-----------------
1000
<?
$_conf__url = array();
$_conf__url[] = "http://도메인1.com/test.php" ;
$_conf__url[] = "http://도메인2.com/test.php" ;
$_conf__url[] = "http://도메인3.com/test.php" ;
$_conf__url[] = "http://도메인4.com/test.php" ;
$_conf__url[] = "http://도메인5.com/test.php" ;
$_conf__url[] = "http://도메인6.com/test.php" ;
$_conf__url[] = "http://도메인7.com/test.php" ;
$_conf__url[] = "http://도메인8.com/test.php" ;
$_conf__url[] = "http://도메인9.com/test.php" ;
$_conf__url[] = "http://도메인10.com/test.php" ;
$cnt=count($_conf__url);
$resultset=array();
for( $i = 0; $i < $cnt; $i++ ){
$url = $_conf__url[$i];
ini_set("allow_url_fopen", 1);
echo $resultset[$url] = file_get_contents($url);
}
?>
-------------------------------------출력화면-----------------
1000
234
2323
235
23523
2352
232
123
123
152
-------------------------------------------------출력화면--------------------
이렇게 http://도메인(1~10).com/test.php 이페이지안에 있는 숫자값이 출력됩니다. 여기서 출력화면에 표시된 숫자를 다 더하고 싶은거에요^^
이렇게 http://도메인(1~10).com/test.php 이페이지안에 있는 숫자값이 출력됩니다. 여기서 출력화면에 표시된 숫자를 다 더하고 싶은거에요^^
$sum = $sum + $resultset[$url];
echo $sum;
echo $sum;
이걸 원하시는건가;;
물론 echo $sum; 은 for 밖으로...
그러니깐 배열 $_conf__url[] 안의 url 의페이지에 숫자가 입력되어있습니다.
지금 보여드린 소스는 그숫자를 나열하는 소스이죠?
지금 보여드린 소스는 그숫자를 나열하는 소스이죠?
결론: url페이지 에 있는 숫자를 123+124+1244+1252363+2341+12124+125125+125+125 이런식으로 더하고 싶은거에요...ㅠㅠ 제가 설명이 부족해서 죄송합니다...
?> 바로 윗라인에
echo array_sum($resultset); 이걸 추가해 보세요..
답변을 작성하시기 전에 로그인 해주세요.