본인을 올바르게 이해하면 아래와 같은 source_file.htm이 있습니다.
<!DOCTYPE html>
<html>
<body>
<img src="myprettypicture.jpg" alt="myprettypicture.jpg" height="50" width="50">
<img src="mynotsoprettypicture.jpg" alt="mynotsoprettypicture.jpg" height="50" width="50">
</body>
</html>
지금, 그 같은 images.ini
파일에 이미지의 ALT 태그에 대한 교체를 저장하는 것이 좋습니다.
<?php
$ini_array = parse_ini_file("images.ini"); // load "images.ini" into array
foreach($ini_array as $key => $val)
{
$img[] = 'alt="' . $key . '"';
$alt[] = 'alt="' . $val . '"';
}
$source = file_get_contents('source_file.htm'); // get Your "source_file.htm"
$target = str_replace($img, $alt, $source); // make all required replacements
file_put_contents('target_file.htm', $target); // save the result to "target_file.htm"
?>
가 얻을 수있는 target_file.htm
<!DOCTYPE html>
<html>
<body>
<img src="myprettypicture.jpg" alt="Here's a pretty picture" height="50" width="50">
<img src="mynotsoprettypicture.jpg" alt="Here's a not so pretty picture" height="50" width="50">
</body>
</html>
참조 :
myprettypicture.jpg = "Here's a pretty picture"
mynotsoprettypicture.jpg = "Here's a not so pretty picture"
지금이 PHP 스크립트를 실행할 수 있습니다 str_replace, 정확히 무엇을의 parse_ini_file, file_get_contents, file_put_contents
I 검색되었습니다 hing : 이미지 폴더를위한 일종의 .ini 래퍼. 당신이 가진 코멘트에 대해 많은 도움을 주셔서 감사합니다. – mediaklan