<?php
if( the_field('result') === 'Win') {
$tmpl = <<<EOFSCRIPT
<script type="text/javascript">
var kof1 = %f, kof2 = %f, total_Sum;
total_Sum = kof1 * kof2;
document.write(total_Sum);
</script>
EOFSCRIPT;
printf( $tmpl, the_field('koff'), the_field('summa'));
} else {
echo '0';
}
?>
@
устарел и не работает в PHP начиная с версии 5.5.0 (см. CURLOPT_POSTFIELDS) $post_data = array("file1" => '@'.$image_path);
$post_data = array("file1" => new CURLFile($image_path));
case 'A':
case 'B':
// do something for either A or B
break;
<?php
$arr = [
//...
11 => true,
12 => true,
15 => false,
16 => true,
17 => false,
18 => false
//...
];
function group($arr) {
$out = [];
$v_in = reset($arr);
$k_in = $k_out = key($arr);
while( $k_out !== null) {
$v = next($arr);
$k = key($arr);
if( null !== $k && $v === $v_in) {
$k_out = $k;
continue;
}
$out[] = sprintf('%d - %d %s', $k_in, $k_out, $v_in ? 'true' : 'false');
$k_in = $k_out = $k;
$v_in = $v;
}
return $out;
}
print_r( group($arr));
/* Array
(
[0] => 11 - 12 true
[1] => 15 - 15 false
[2] => 16 - 16 true
[3] => 17 - 18 false
) */
attachment
. В этом поле просто через запятую идут строки типа photo-123_456
, идентифицирующие прикладываемые картинки.public function msgSend($msg, $uid, $token, $attachment = '' ){
$request_params = array(
'message' => $msg,
'user_id' => $uid,
'attachment' => $attachment,
'access_token' => $token,
'v' => self::API_VERSION
);
$v->msgsend("мои команды", $uid, $token, "photo-123_456");
<?php
for($i=0; $i<=10; $i++) {
echo "$i - " . f($i) . "\n";
}
function f($s) {
return crc32($s) & 0x7FFFFFFF;
}
/*
0 - 1960566561
1 - 64810935
2 - 450215437
3 - 1842515611
4 - 1941314360
5 - 78719918
6 - 498629140
7 - 1790921346
8 - 2046842643
9 - 218589061
10 - 559752673
*/
<tbody>
:<?php
foreach ($params['oldAttributes'] as $oldName => $oldValue) {
$newValue = $params['newAttributes'][$oldName];
printf( "<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n",
$oldName,
$oldValue,
$newValue === $oldValue ? '' : $newValue
);
}
?>
upload.wikimedia.org
$search = 'b';
$json = '{"1":{"name":"Browser"},"2":{"name":"Браузер"},"3":{"name":"Повар"},"4":{"name":"bонки"}}';
$data = json_decode($json);
$found = array();
foreach($data as $entry) {
$name = $entry->name;
if( false !== mb_stristr( $name, $search)) {
array_push( $found, $name);
}
}
print_r($found);
/* Array
(
[0] => Browser
[1] => bонки
) */
function cmp($a, $b) {
if ($a[2] == $b[2]) return 0;
return ($a[2] < $b[2]) ? -1 : 1;
}
);
usort($array, "cmp");
image.png|image.jpg|image.gif|audio.mp3