我试图从cURL响应数组中获取数值。但无法做到这一点。我使用此代码
<?php
?>
<?php get_header(); ?>
<!-- Start body -->
<body <?php body_class(); ?>>
<!-- Hier geht der Wrapper auf-->
<div class="wrapper">
<!-- Get Logo -->
<?php get_template_part( 'logo' ); ?>
<div class="clear"></div>
<!-- Wordpress verbieten, <p>-Tags zu setzen -->
<?php remove_filter ('the_content', 'wpautop'); ?>
<!-- T H E L O O P -->
<?php if ( have_posts() ): ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="article-content" id="post-<?php the_ID(); ?>">
<div class="article-thumb">
<?php the_content(); ?>
<div class="theid"><?php the_ID(); ?></div>
<?php if (in_category( "28" )){
echo '<a href="';
echo '#';
echo '" target="_blank"> link</a>';
}
else { echo 'Hi!'; ?>
<!-- Close article-thumb -->
</div>
<!-- Close article-content -->
</div>
<?php endwhile; ?>
<?php endif; ?>
<!-- /T H E L O O P -->
<!-- Clear -->
<div class="clear"></div>
<?php else: ?>
<h2>No posts to display</h2>
<?php endif; ?>
<?php wp_reset_query(); ?>
<!-- bottomnav -->
<div class="bottomnav"><a class="super next"><?php posts_nav_link(' / ','Zurück','Weitere Projekte'); ?></a></div>
<!-- Infinite Scroll -->
<script type="text/javascript">
$('.wrapper').infinitescroll({
loading: {
finished: undefined,
finishedMsg: "End.",
img: "http://www.injuvik.de/wp-content/themes/injuvik/img/pfeilnachunten.png",
msg: null,
msgText: "Loading..",
selector: null,
speed: 'fast',
start: undefined
},
navSelector: "div.bottomnav",
nextSelector: "div.bottomnav a:last",
itemSelector: "div.wrapper div.article-content",
animate: false
});
</script>
</div>
<!-- toggle class on click -->
<script>
$('body').on('click', 'div.article-content', function(){
$( this ).toggleClass( "bigger" );
});
</script>
<?php get_footer(); ?>
它打印此我们的新发票ID是:[{-10191}] 在页面上。现在我想从数组中获取10191。我尝试了这个,但失败了。
var ar_val=[];
$("form").find("[id$='PFtxtname']").each(function () {
var txtv = $(this).val().trim();
ar_val.push(txtv);
});
我如何检索数值?
答案 0 :(得分:2)
如果$returndata
与字符串
将此信息放在curl_exec:
之后<?php
$urltopost = "http://www.xxxx.yyy.com/zzz.php";
$ch = curl_init ($urltopost);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$returndata = curl_exec ($ch);
//$returndata = 'Our new Invoice (ID) is: [{-10191}]';
preg_match_all("/\{([^\]]*)\}/", $returndata, $matches);
$invoiceID = intval(ltrim($matches[1][0], '-'));
print_r($invoiceID);