これを達成することは可能ですか?
私はいくつかの配列を持っています
Array
(
[1] => Model_Like Object
(
[_is_new:protected] =>
[_frozen:protected] =>
[_data:protected] => Array
(
[id] => 1
[user_id] => 5
[liked_by] => 1
)
[_custom_data:protected] => Array
(
)
[_original:protected] => Array
(
[id] => 1
[user_id] => 5
[liked_by] => 1
)
[_data_relations:protected] => Array
(
)
[_original_relations:protected] => Array
(
)
[_reset_relations:protected] => Array
(
)
[_view:protected] =>
[_iterable:protected] => Array
(
)
)
[2] => Model_Like Object
(
[_is_new:protected] =>
[_frozen:protected] =>
[_data:protected] => Array
(
[id] => 2
[user_id] => 5
[liked_by] => 2
)
[_custom_data:protected] => Array
(
)
[_original:protected] => Array
(
[id] => 2
[user_id] => 5
[liked_by] => 2
)
[_data_relations:protected] => Array
(
)
[_original_relations:protected] => Array
(
)
[_reset_relations:protected] => Array
(
)
[_view:protected] =>
[_iterable:protected] => Array
(
)
)
[4] => Model_Like Object
(
[_is_new:protected] =>
[_frozen:protected] =>
[_data:protected] => Array
(
[id] => 4
[user_id] => 5
[liked_by] => 6
)
[_custom_data:protected] => Array
(
)
[_original:protected] => Array
(
[id] => 4
[user_id] => 5
[liked_by] => 6
)
[_data_relations:protected] => Array
(
)
[_original_relations:protected] => Array
(
)
[_reset_relations:protected] => Array
(
)
[_view:protected] =>
[_iterable:protected] => Array
(
)
)
)
そして、一致する結果を1つだけ表示したいと思います。
<?php foreach ($user->likes as $likes): ?>
<?php if($likes['liked_by'] == $logged_in_user_id): ?>
<?php echo "you like it" ?>
<?php else: ?>
<?php echo "you dont like it" ?>
<?php endif; ?>
<?php endforeach; ?>
このようにして、次の結果が得られます
you like it you dont like it you dont like it
matchigの結果のみを表示する場所はありますか?