Jump to content

Stuck in function


retoto

Recommended Posts

<?php

$array = array(0 => "bleu", 1 => "bleu", 2 => "ghgf", 3 => "gfhfgh");

$key = array_search('bleu', $array);

echo #key;

?>

 

 

you can see that i search "bleu"

and i have two from that in array

and this print on page only one...

how can i print two thing ?

(0,1)

 

thanks

Link to comment
Share on other sites

<?php
$array = array(0 => "bleu", 1 => "bleu", 2 => "ghgf", 3 => "gfhfgh");
$keys = array_keys($array, 'bleu'); 
print_r($keys);
?>

 

thanks man

but out pot

" Array ( [0] => 0 [1] => 1 )  "

how can i print only 0 and 1 without all this :\?

Link to comment
Share on other sites

you mean like that :S?

 

<?php

$array = array(0 => "bleu", 1 => "bleu", 2 => "ghgf", 3 => "gfhfgh");

for ($i=0;$i<=4;$i++) {

$keys = array_keys($array[$i], 'bleu');

echo $keys;

}

?>

 

Warning: array_keys() [function.array-search]: Wrong datatype for second argument in *********** on line 4

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.