Jump to content
php.lv forumi

Izvadīt arraya elementu


upiz

Recommended Posts

Ir vajadzīgs lai noteiktā laikā rādītu savu tekstu...

kā lai izvada arraya otro elementu?

$laiks = '9.30';
$tim = array(
	'8.00' => 'pirmais',
	'9.00' => 'otrais',
	'10.00' => 'tresais' 
	);
$i=0;
foreach ($tim as $lks => $not) {
if ($laiks>=$lks) {
	$i++;
}
}
//izvada 2, bet kaa lai to sasaista ar $tim arrayu?
echo $i;

Link to comment
Share on other sites

Minūtes konkrētajā gadījumā izskatās liekas, attiecīgi varētu palikt tikai pie stundu čekošanas.

No performances viedokļa - cikls nepatērēs praktiski necik laika. Protams, ja gribi, vari droši sarakstīt pilnu masīvu - 24 elementi, izpildes laiks būs ~ tas pats.

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...