PHP Нахождение элемента массива с наибольшим или наименьшим значением

Для нахождения наибольшего элемента используйте функцию max():
$largest = max($array);

Для нахождения наименьшего элемента используйте функцию min():
$smallest = min($array);

Обычно функция max() возвращает наибольший из двух элементов, но если ей передается массив, то она осуществляет поиск среди элементов массива. К сожалению, при использовании функции max() нельзя узнать индекс наибольшего элемента. Чтобы это  делать, необходимо отсортировать массив в порядке убывания, поместив наибольший элемент в нулевую позицию:

arsort($array);

Теперь значение наибольшего элемента находится в $array[0].

Если не хотите затрагивать порядок исходного массива, то сделайте копию и отсортируйте ее:

$copy = $array;
arsort($copy);

Та же идея применима и к функции min(), но вместо функции arsort() используйте функцию asort().

Installing windows on samsung ultrabook 5 series np530u3c

First of all, make sure you remove the USB from which you installed Windows, when it is about to restart the first time (after copying files). If it still won’t boot your new installation then yes, it’s probably because Windows Setup sees the iSSD (ExpressCache) as the boot drive and places it’s 100MB SYSTEM partition on it.

Here’s the easiest fix if that happens:

1) Let it boot into Windows Setup again (ie leave that USB in). Once you get past the welcome screen, hit Shift-F10 to get a command prompt.

2) Use XCOPY /E /H /R to copy everything (including hidden files) from that SYSTEM partition (on the iSSD) to the partition where you installed Windows.

Before copying, use DIR /A commands to determine what the drive letters are for those partitions: DIR /A C: and DIR /A D: and DIR /A E: etc. The SYSTEM partition (on the iSSD) should contain a BOOT folder and a bootmgr file. The partition where you installed Windows should contain, you guessed it, a Windows folder 😀

So if your SYSTEM partition (with the boot files) is drive C, and your Windows partition is drive E (for example) use the following XCOPY command: XCOPY /E /H /R C:\ E:\ Make sure you get the forward and backward slashes right, they’re important.

3) Now that the Windows partition contains the necessary boot files, we have to make sure it’s flagged Active (bootable). Enter the command DISKPART.

4) At the DISKPART> prompt, use LIST DISK to determine the disk number of your HDD (or SDD). Obviously, it’s the big one (xxx GB) while the small one is the iSSD (xxx MB). Now use SELECT DISK to select the big disk, say SELECT DISK 1.

5) Still at the DISKPART> prompt, use LIST PARTITION to determine the partition number of your Windows partition. If you installed Windows on a blank disk, it’s probably the first partition. Now use SELECT PARTITION to select the Windows partition, say SELECT PARTITION 1

6) Still at the DISKPART> prompt, use DETAIL PARTITION to verify you got the right partition.

7) Still at the DISKPART> prompt, use ACTIVE to flag your (now selected) Windows partition Active and bootable.

8) Use Exit to leave DISKPART. Exit again to leave the command prompt. Close down Windows setup. Remove the USB. Reboot.

Куда chkdsk пишет лог ?

Куда chkdsk пишет лог, если он запустился при старте после некорректного завершения ?

Applications log. И пишет он туда как источник: Winlogon; EventID 1001

Checking file system on C:
The type of the file system is NTFS.
Volume label is main.

One of your disks needs to be checked for consistency. You
may cancel the disk check, but it is strongly recommended
that you continue.
Windows will now check the disk.
The record length 0x11477982 of attribute of type 0xffffff00 and
instance tag 0x0 in file 0x24c6 is not aligned.
Truncating badly linked attribute records
from file record segment 9414.
Cleaning up minor inconsistencies on the drive.
Cleaning up 135 unused index entries from index $SII of file 0x9.
Cleaning up 135 unused index entries from index $SDH of file 0x9.
Cleaning up 135 unused security descriptors.
Windows has made corrections to the file system.

39078080 KB total disk space.
17360792 KB in 73165 files.
22608 KB in 6614 indexes.
0 KB in bad sectors.
157524 KB in use by the system.
65536 KB occupied by the log file.
21537156 KB available on disk.

4096 bytes in each allocation unit.
9769520 total allocation units on disk.
5384289 allocation units available on disk.

Windows has finished checking your disk.
Please wait while your computer restarts.

Zenburn theme for Notepad++

Notepad++

By default I love the zenburn theme for Notepad++. Very easy on the eyes. However, the fold lines were a bold red and jumped out horribly. There are about 5 additional tweaks I made as well to blend it a little better. I copied some additional styles over from the default notepad++ theme and then modified them to match the color scheme of current zenburn.

zenburn-notepad-theme

I think it looks a lot better. To update your zenburn theme with mine simply download my “Zenburn.xml” (right click and save as) file and replace it over your current one which is located here:

1
C:\Program Files (x86)\Notepad++\themes

Одинарные и двойные кавычки в PHP

Image

Применять одинарные или двойные кавычки, надо правильно и по необходимости. Интерпретатор, который “читает” ваш код, строчку в одинарных кавычках будет проходить быстро, а строчку в двойных кавычках будет изучать с пристрастием, пытаясь найти переменные, вместо которых ему надо поставить конкретные значения.

Поэтому, если в вашей строке нет переменных, используйте одинарные кавычки, чтобы интерпретатор не терял время на изучение этих строк.

Если в вашей строке уже присутствуют кавычки, то можно поступить двумя способами. Первый не самый удачный – экранировать кавычки в строке специальным символом обратной косой черты (\), этот символ надо поставить перед кавычкой, которую надо “скрыть” от интерпретатора:

echo '<a href=\'/static/link\' title=\'Yeah yeah!\'>Link name</a>';

Согласитесь, что чтение такого кода человеком сильно затрудняется. Лучше применяйте смешанный способ кодирования – ставьте одинарные кавычки в качестве рабочих, для интерпретатора, а кавычки внутри строки сделайте двойные или наоборот, если в строке присутствуют еще и переменные:

echo '<a href="/static/link" title="Yeah yeah!">Link name</a>';
echo "<a href='$link' title='$linktitle'>$linkname</a>";

Ошибка запуска Openserver в windows 7. Защита файла hosts от записи.

l2

На windows 7 файл hosts защищен от записи в него сторонним не доверенным ПО. По этому, при настройках безопасности по умолчанию, запуск OpenServer будет выполняться с ошибкой:

Файл C:\Windows\system32\drivers\etc\hosts недоступен для записи
Запуск будет продолжен в ограниченном режиме
Запуск сервера без доменов невозможен
Сбой запуска!

Чтобы разрешить OpenServer редактировать файл hosts нужно выполнить следующие действия:
1. Открыть cmd.exe (win + r)
2. Выполнить там команду:

attrib.exe -s -r -h -a C:\Windows\system32\drivers\etc\hosts

Если это не помогло, значит у вас скорее всего запущено антивирусное ПО, которое блокирует файл самостоятельно. В этом случаем можно в настройках ПО добавить исполняемый файл openserver в доверенные.