English 中文(简体)
需要帮助才能将循环转换为可以用于php 对象的东西
原标题:Need help in converting a loop into something that can be used in an php object

这个独立代码完美运作

$pdf
->addPDF( ../docx/tag_1.pdf ,  all )
->addPDF( ../docx/tag_2.pdf ,  all )
->addPDF( ../docx/tag_3.pdf ,  all )
->merge( file ,  merged.pdf );

我需要的是能够动态地创建一个循环, 从一个维持所创建标签数的变量中添加标签, 例如 :

$pdf

启动环环循环

->addPDF("../docx/tag_{$count}.pdf",  all )
->addPDF("../docx/tag_{$count}.pdf",  all )
->addPDF("../docx/tag_{$count}.pdf,  all )

循环结束之前的 等等

->merge( file ,  merged.pdf );

怎样才能达到这个目标?

最佳回答

试这个

$number_of_tags = 7;

for($i = 1; $i <= $number_of_tags; $i++)
{
    $pdf->addPDF( ../docx/tag_ .$i. .pdf ,  all );
}

$pdf->merge( file ,  merged.pdf );
问题回答
for ($i = 1; $i <= 3; $i++) {
    $pdf->addPDF("../docx/tag_$i.pdf",  all );
}
$pdf->merge( file ,  merged.pdf );




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签