php - 用一系列序列号替换短代码中的内容
问题描述
我需要用一系列序列号替换我的简码中的内容(因此,无论我在两个这样的简码标签之间放置一些内容,它都需要用一个按顺序排列的数字替换它。)
这是我尝试使用的代码,
function ref_shortcode( $atts , $content = null ) {
ob_start();
for ($x = 0; $x <= 10; $x++) {
$numbers = $x;
echo '<a>' . $numbers . '</a>';
return ob_get_clean();
}
}
add_shortcode( 'ref', 'ref_shortcode' );
代码的问题是它用 0 替换了每个短代码。代码中是否有错误?我不希望它按顺序排列(0,1,2,3,4,5......)
解决方案
推荐阅读
- karate - 如何针对字符串值断言整数值
- ruby-on-rails - 通过邮递员通过 API 使用 Rails 主动存储上传文件(.pdf、.jpg 等)?(不通过 Rails 视图)
- spring-webflux - 针对 FreeMarker 问题的 Spring WebFlux 配置
- javascript - 在发送标头之前等待来自 Chrome 原生消息传递应用程序的响应
- blazor - 在 Blazor 的 Startup 类中找不到 IComponentsApplicationBuilder 类型
- c++ - 使用花括号构造一个不使用 initializer_list 的对象
- javascript - Omit action in "if" statement in JavaScript
- python - Remove null columns from a pyspark dataframe
- python - 如何处理 + 不受支持的操作数类型:数据框中的“十进制.十进制”和“浮点数”
- spring-kafka - Kafka Listener Concurreny - How to handle Stop/Idle events fired from 6 threads