echo 수 더하기 질문입니다. 채택완료
narasarang
11년 전
조회 6,335
안녕하세요 밑에 http://도메인(번호1부터10).com/test.php" target="_blank">http://도메인(번호1부터10).com/test.php 에 숫자가 들어있는데요
그냥 아래소스로 하면 숫자 10개만 출력 됩니다. 그 숫자를 더한값(합한값) 으로 나타낼수 있나요? 도와주세요^^
$_conf__url = array();
$_conf__url[] = "http://도메인1.채ㅡ" target="_blank">http://도메인1.com/test.php" ;
$_conf__url[] = "http://도메인2." target="_blank">http://도메인2.com/test.php" ;
$_conf__url[] = "http://도메인3." target="_blank">http://도메인3.com/test.php" ;
$_conf__url[] = "http://도메인4." target="_blank">http://도메인4.com/test.php" ;
$_conf__url[] = "http://도메인5." target="_blank">http://도메인5.com/test.php" ;
$_conf__url[] = "http://도메인6." target="_blank">http://도메인6.com/test.php" ;
$_conf__url[] = "http://도메인7." target="_blank">http://도메인7.com/test.php" ;
$_conf__url[] = "http://도메인8." target="_blank">http://도메인8.com/test.php" ;
$_conf__url[] = "http://도메인9." target="_blank">http://도메인9.com/test.php" ;
$_conf__url[] = "http://도메인10." target="_blank">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개
채택된 답변
+20 포인트
11년 전
이렇게 하고 싶으신거에요?
<?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? <a href="http://www.domain" target="_blank" rel="noopener noreferrer">http://www.domain</a>".$vals.".com/test.php
");
}
?>
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
댓글을 작성하려면 로그인이 필요합니다.
11년 전
그러니깐 배열 $_conf__url[] 안의 url 의페이지에 숫자가 입력되어있습니다.
지금 보여드린 소스는 그숫자를 나열하는 소스이죠?
결론: url페이지 에 있는 숫자를 123+124+1244+1252363+2341+12124+125125+125+125 이런식으로 더하고 싶은거에요...ㅠㅠ 제가 설명이 부족해서 죄송합니다...
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
11년 전
$sum = $sum + $resultset[$url];
echo $sum;
이걸 원하시는건가;;
물론 echo $sum; 은 for 밖으로...
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
11년 전
다시 질문하겠습니다.ㅜㅜ
$_conf__url = array();
$_conf__url[] = "http://도메인1.채ᅳ/" target="_blank">http://도메인1.com/test.php" ;
$_conf__url[] = "http://도메인2./" target="_blank">http://도메인2.com/test.php" ;
$_conf__url[] = "http://도메인3./" target="_blank">http://도메인3.com/test.php" ;
$_conf__url[] = "http://도메인4./" target="_blank">http://도메인4.com/test.php" ;
$_conf__url[] = "http://도메인5./" target="_blank">http://도메인5.com/test.php" ;
$_conf__url[] = "http://도메인6./" target="_blank">http://도메인6.com/test.php" ;
$_conf__url[] = "http://도메인7./" target="_blank">http://도메인7.com/test.php" ;
$_conf__url[] = "http://도메인8./" target="_blank">http://도메인8.com/test.php" ;
$_conf__url[] = "http://도메인9./" target="_blank">http://도메인9.com/test.php" ;
$_conf__url[] = "http://도메인10./" target="_blank">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)." target="_blank">http://도메인(1~10).com/test.php" target="_blank">http://도메인(1~10).http://도메인(1~10).com/test.php" target="_blank">com/test.php 이페이지안에 있는 숫자값이 출력됩니다. 여기서 출력화면에 표시된 숫자를 다 더하고 싶은거에요^^
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인