比较两个字符串,我做错了什么? [英] comparing two strings, what am I doing wrong?

查看:50
本文介绍了比较两个字符串,我做错了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我现在正在使用Facebook API,我有一个

问题,但我不知道我做错了什么。


所以我有一些数组,f.ex。:


用户专辑:


数组(2){

[0] =>

数组(10){

["援助"] =>

string(19)" 2322329421568036697"

[" cover_pid"] =>

string(19 )" 2322329421568483956"

[" owner"] =>

string(9)" 540709454"

[" name" ;] =>

string(5)" test2"

[" created"] =>

string(10) " 1212610115"

[" modified"] =>

string(10)" 1212610148"

[" description" ] =>

string(42)"描述2balaldlsaüdkopasjdkajdaj"

[" location"] =>

string (9)Locat ion2"

[" link"] =>

string(56)" http://www.facebook.com/album.php?

aid = 20313& id = 540709454"

[" size"] =>

string(1)" 6"

}

[1] =>

数组(10){

["援助]] =>

string(19)" 2322329421568036696"

[" cover_pid"] =>

string(19)" 2322329421568483947"

[" owner"] =>

string(9)" 540709454"

[" name"] =>

string(5)" test1"

[" created"] =>

string(10)" 1212609951"

[" modified"] =>

string(10)" 1212610028"

[" description"] =>

string(23)" Description 1 blablabla"

[" location"] =>

string(9)" Location1"

[" link"] =>

string(56)" http://www.facebook.com/album.php?

aid = 20312& id = 540709454"

[" size"] =>

string(1)" 9"

}

}

用户照片:


数组(15){

[0] =>

数组(8) ){

[" pid"] =>

string(19)" 2322329421568483956"

[" aid"] = >

string(19)" 2322329421568036697"

[" src_small"] =>

string(95)" http ://photos-e.ak.facebook.com/photos-ak-sf2p/

v258 / 189/57 / 540709454 / t540709454_467572_7021.jpg"

[" src_big"] =>

string(95)" http://photos-e.ak.facebook.com/photos-ak-sf2p/

v258 / 189/57/540709454 / n540709454_467572_7021.jpg"

[" src"] =>

string(95)" http://photos-e.ak .facebook.com / photos-ak-sf2p /

v258 / 189/57 / 540709454 / s540709454_4675 72_7021.jpg"

[" link"] =>

string(57)" http://www.facebook.com/photo.php?

pid = 467572& id = 540709454"

[" caption"] =>

string(9)" caption21"

[" created"] =>

string(10)" 1212610147"

}

[1 ] =>

array(8){

[" pid"] =>

string(19)" 2322329421568483957"

["援助]] =>

string(19)" 2322329421568036697"

[" src_small"] =>

string(95)" http://photos-f.ak.facebook.com/photos-ak-sf2p/

v258 / 189/57 / 540709454 / t540709454_467573_7347.jpg"

[" src_big"] =>

string(95)" http://photos-f.ak.facebook.com/photos -ak-sf2p /

v258 / 189/57/540709454 / n540709454_467573_7347.jpg"

[" src"] =>

string(95)" http://photos-f.ak.f acebook.com/photos-ak-sf2p/

v258 / 189/57 / 540709454 / s540709454_467573_7347.jpg"

[" link"] =>

string(57)" http://www.facebook.com/photo.php?

pid = 467573& id = 540709454"

[ " caption"] =>

string(9)" caption22"

[" created"] =>

string (10)1212610147

}

[2] =>

array(8){

[" pid"] =>

string(19)" 2322329421568483958"

["援助"] =>

string(19)" 2322329421568036697"

[" src_small"] =>

string(95)" http://photos-g.ak。 facebook.com/photos-ak-sf2p/

v258 / 189/57 / 540709454 / t540709454_467574_7613.jpg"

[" src_big"] =>

string(95)" http://photos-g.ak.facebook.com/photos-ak-sf2p/

v258 / 189/57 / 540709454 / n540709454_467574_7613.jpg" ;

[" src"] =>

string(95)" http://photos-g.ak.facebook.com/photos-ak-sf2p/

v258 / 189/57 / 540709454 / s540709454_467574_7613.jpg"

[" link"] =>

string(57)" http: //www.facebook.com/photo.php?

pid = 467574& id = 540709454"

[" caption"] =>

string(9)" caption23"

[" created"] =>

string(10)" 1212610147"

......

[9] =>

array(8){

[" pid"] = >

string(19)" 2322329421568483950"

[" aid"] =>

string(19)" 2322329421568036696" ;

[" src_small"] =>

string(95)" http://photos-g.ak.facebook.com/photos-ak- sf2p /

v258 / 189/57 / 540709454 / t540709454_467566_6827.jpg"

[" src_big"] =>

string(95 )http://photos-g.ak.facebook.com/photos- ak-sf2p /

v258 / 189/57/540709454 / n540709454_467566_6827.jpg"

[" src"] =>

string (95)http://photos-g.ak.facebook.com/photos-ak-sf2p/

v258 / 189/57 / 540709454 / s540709454_467566_6827.jpg"

[" link"] =>

string(57)" http://www.facebook.com/photo.php?

pid = 467566& id = 540709454"

[" caption"] =>

string(8)" caption4"

["已创建"] =>

string(10)" 1212610025"

}

[10] =>

array(8){

[" pid"] =>

string(19)" 2322329421568483951"

[ "援助" =>

string(19)" 2322329421568036696"

[" src_small"] =>

string (95)http://photos-h.ak.facebook.com/photos-ak-sf2p/

v258 / 189/57 / 540709454 / t540709454_467567_7106.jpg"

[" src_big&quo t;] =>

string(95)" http://photos-h.ak.facebook.com/photos-ak-sf2p/

v258 / 189/57/540709454 / n540709454_467567_7106.jpg"

[" src"] =>

string(95)" http://photos-h.ak .facebook.com / photos-ak-sf2p /

v258 / 189/57 / 540709454 / s540709454_467567_7106.jpg"

[" link"] =>

string(57)" http://www.facebook.com/photo.php?

pid = 467567& id = 540709454"

[" caption"] =>

string(8)" caption5"

[" created"] =>

string(10)" 1212610025"


有这个帮助,它是专辑ID,我想只显示

特殊援助的图片,所以我写了这个:


for($ i = 0; $ i< count($ albums); $ i ++){

echo"< ; br>< b>"。$ albums [$ i] [''name'']。"< / b>< br>" ;;

$ album_aid = $专辑[$ i] [''援助''];

for($ j = 0; $ j< count($ photos); $ j ++){

$ photo_aid = $ photos [$ j] [''aid''];

if($ photo_aid == $ album_aid){

echo $ album_aid。" "。$ photo_aid;

echo"< a href = \""。$ photos [$ j] [''link'']。" \"> ;< img src = \""。$ photos [$ j]

['src_small'']。" \" ALT = \" Photo\"边界= \" 0\" />< / a>" ;;

}

}

echo"< br>" ;;

}


但是我一直在向我展示所有的照片,即使这些照片不同于b
。我查看了手册,但我不知道我在做什么

错了。有人可以帮帮我吗?

解决方案

i = 0;


i< count(


相册);

Hi,

I am working with the Facebook API right now, an I have kind of a
problem, but I don''t know what I am doing wrong.

So I have a few arrays, f.ex.:

User albums:

array(2) {
[0]=>
array(10) {
["aid"]=>
string(19) "2322329421568036697"
["cover_pid"]=>
string(19) "2322329421568483956"
["owner"]=>
string(9) "540709454"
["name"]=>
string(5) "test2"
["created"]=>
string(10) "1212610115"
["modified"]=>
string(10) "1212610148"
["description"]=>
string(42) "Description 2 balaldlsaüdkopas jdkaj daj"
["location"]=>
string(9) "Location2"
["link"]=>
string(56) "http://www.facebook.com/album.php?
aid=20313&id=540709454"
["size"]=>
string(1) "6"
}
[1]=>
array(10) {
["aid"]=>
string(19) "2322329421568036696"
["cover_pid"]=>
string(19) "2322329421568483947"
["owner"]=>
string(9) "540709454"
["name"]=>
string(5) "test1"
["created"]=>
string(10) "1212609951"
["modified"]=>
string(10) "1212610028"
["description"]=>
string(23) "Description 1 blablabla"
["location"]=>
string(9) "Location1"
["link"]=>
string(56) "http://www.facebook.com/album.php?
aid=20312&id=540709454"
["size"]=>
string(1) "9"
}
}

User photos:

array(15) {
[0]=>
array(8) {
["pid"]=>
string(19) "2322329421568483956"
["aid"]=>
string(19) "2322329421568036697"
["src_small"]=>
string(95) "http://photos-e.ak.facebook.com/photos-ak-sf2p/
v258/189/57/540709454/t540709454_467572_7021.jpg"
["src_big"]=>
string(95) "http://photos-e.ak.facebook.com/photos-ak-sf2p/
v258/189/57/540709454/n540709454_467572_7021.jpg"
["src"]=>
string(95) "http://photos-e.ak.facebook.com/photos-ak-sf2p/
v258/189/57/540709454/s540709454_467572_7021.jpg"
["link"]=>
string(57) "http://www.facebook.com/photo.php?
pid=467572&id=540709454"
["caption"]=>
string(9) "caption21"
["created"]=>
string(10) "1212610147"
}
[1]=>
array(8) {
["pid"]=>
string(19) "2322329421568483957"
["aid"]=>
string(19) "2322329421568036697"
["src_small"]=>
string(95) "http://photos-f.ak.facebook.com/photos-ak-sf2p/
v258/189/57/540709454/t540709454_467573_7347.jpg"
["src_big"]=>
string(95) "http://photos-f.ak.facebook.com/photos-ak-sf2p/
v258/189/57/540709454/n540709454_467573_7347.jpg"
["src"]=>
string(95) "http://photos-f.ak.facebook.com/photos-ak-sf2p/
v258/189/57/540709454/s540709454_467573_7347.jpg"
["link"]=>
string(57) "http://www.facebook.com/photo.php?
pid=467573&id=540709454"
["caption"]=>
string(9) "caption22"
["created"]=>
string(10) "1212610147"
}
[2]=>
array(8) {
["pid"]=>
string(19) "2322329421568483958"
["aid"]=>
string(19) "2322329421568036697"
["src_small"]=>
string(95) "http://photos-g.ak.facebook.com/photos-ak-sf2p/
v258/189/57/540709454/t540709454_467574_7613.jpg"
["src_big"]=>
string(95) "http://photos-g.ak.facebook.com/photos-ak-sf2p/
v258/189/57/540709454/n540709454_467574_7613.jpg"
["src"]=>
string(95) "http://photos-g.ak.facebook.com/photos-ak-sf2p/
v258/189/57/540709454/s540709454_467574_7613.jpg"
["link"]=>
string(57) "http://www.facebook.com/photo.php?
pid=467574&id=540709454"
["caption"]=>
string(9) "caption23"
["created"]=>
string(10) "1212610147"
......
[9]=>
array(8) {
["pid"]=>
string(19) "2322329421568483950"
["aid"]=>
string(19) "2322329421568036696"
["src_small"]=>
string(95) "http://photos-g.ak.facebook.com/photos-ak-sf2p/
v258/189/57/540709454/t540709454_467566_6827.jpg"
["src_big"]=>
string(95) "http://photos-g.ak.facebook.com/photos-ak-sf2p/
v258/189/57/540709454/n540709454_467566_6827.jpg"
["src"]=>
string(95) "http://photos-g.ak.facebook.com/photos-ak-sf2p/
v258/189/57/540709454/s540709454_467566_6827.jpg"
["link"]=>
string(57) "http://www.facebook.com/photo.php?
pid=467566&id=540709454"
["caption"]=>
string(8) "caption4"
["created"]=>
string(10) "1212610025"
}
[10]=>
array(8) {
["pid"]=>
string(19) "2322329421568483951"
["aid"]=>
string(19) "2322329421568036696"
["src_small"]=>
string(95) "http://photos-h.ak.facebook.com/photos-ak-sf2p/
v258/189/57/540709454/t540709454_467567_7106.jpg"
["src_big"]=>
string(95) "http://photos-h.ak.facebook.com/photos-ak-sf2p/
v258/189/57/540709454/n540709454_467567_7106.jpg"
["src"]=>
string(95) "http://photos-h.ak.facebook.com/photos-ak-sf2p/
v258/189/57/540709454/s540709454_467567_7106.jpg"
["link"]=>
string(57) "http://www.facebook.com/photo.php?
pid=467567&id=540709454"
["caption"]=>
string(8) "caption5"
["created"]=>
string(10) "1212610025"

There is this aid, it is the album id, and I wanted to only show
pictures of a special aid, so I wrote this:

for($i=0;$i<count($albums);$i++){
echo "<br><b>".$albums[$i][''name'']."</b><br>";
$album_aid = $albums[$i][''aid''];
for($j=0;$j<count($photos);$j++){
$photo_aid = $photos[$j][''aid''];
if($photo_aid == $album_aid){
echo $album_aid." ".$photo_aid;
echo "<a href=\"".$photos[$j][''link'']."\"><img src=\"".$photos[$j]
[''src_small'']."\" alt=\"Photo\" border=\"0\" /></a>";
}
}
echo "<br>";
}

but i keeps showing me all of the pictures, even if the aids are
different. I looked in the manual, but I do not know what I am doing
wrong. Can someone please help me?

解决方案

i=0;


i<count(


albums);


这篇关于比较两个字符串,我做错了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆