Sponsored Content
Top Forums Web Development Notes with Ravinder on Badging System Development Part II Post 303028420 by Neo on Monday 7th of January 2019 09:50:06 PM
Old 01-07-2019
Testing, it seem the comparing cryptographic hashes of the badges array, serialized as a JSON file, do not provide as much consistency as comparing an array stored in the DB with a recently generated array using the PHP function array_diff_assoc():

Code:
array array_diff_assoc ( array $array1 , array $array2 [, array $... ] )

So, tomorrow I will refine the alert code to also use array_diff_assoc() .

Currently am comparing a generated hash with a stored hash as a cookie. This works well, but it could be even better, so I'm going to do both (I think), compare the hashes and also compare the badge arrays. Still testing ...

Also, I'm going to stop posting in the Underground and move this thread to the main forums.
This User Gave Thanks to Neo For This Post:
 

3 More Discussions You Might Find Interesting

1. What is on Your Mind?

New Badging System - Badges Prototype Beta 1 (Badges Only)

Today I mapped out the new badging system using FA icons, Beta 1 in no particular order except a 6 x 8 grid: https://www.unix.com/members/1-albums215-picture991.png The prototype HTML code for this layout: <style> .fa-badge-grid { font-size: 1.5em; } .row { ... (38 Replies)
Discussion started by: Neo
38 Replies

2. What is on Your Mind?

Status of Badging System - Beta 1

Dear All, Here is the current status of the badging system: The Beta 1 phase of the new badging system is close to completion. 42 prototype badges have been "allocated" 6 prototype badge slots are held in reserve The "alert you have new badges" prototype is running and is currently... (4 Replies)
Discussion started by: Neo
4 Replies

3. What is on Your Mind?

Badging System: UNIX.COM Bug Hunter Badge (New)

I have moved the bug badge out of reserve and into the main stream. Basically, I will assign a color level like the others, based on who has made a good actionable bug report for UNIX.COM. "Good" means screenshots, links, and even details from web dev tools our the HTML source code. So far,... (0 Replies)
Discussion started by: Neo
0 Replies
ARRAY_UDIFF_UASSOC(3)							 1						     ARRAY_UDIFF_UASSOC(3)

array_udiff_uassoc - Computes the difference of arrays with additional index check, compares data and indexes by a callback function

SYNOPSIS
array array_udiff_uassoc (array $array1, array $array2, [array $...], callable $value_compare_func, callable $key_compare_func) DESCRIPTION
Computes the difference of arrays with additional index check, compares data and indexes by a callback function. Note that the keys are used in the comparison unlike array_diff(3) and array_udiff(3). PARAMETERS
o $array1 - The first array. o $array2 - The second array. o $value_compare_func - The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. int callback (mixed $a, mixed $b) o $key_compare_func - The comparison of keys (indices) is done also by the callback function $key_compare_func. This behaviour is unlike what array_udiff_assoc(3) does, since the latter compares the indices by using an internal function. RETURN VALUES
Returns an array containing all the values from $array1 that are not present in any of the other arguments. EXAMPLES
Example #1 array_udiff_uassoc(3) example <?php class cr { private $priv_member; function cr($val) { $this->priv_member = $val; } static function comp_func_cr($a, $b) { if ($a->priv_member === $b->priv_member) return 0; return ($a->priv_member > $b->priv_member)? 1:-1; } static function comp_func_key($a, $b) { if ($a === $b) return 0; return ($a > $b)? 1:-1; } } $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),); $result = array_udiff_uassoc($a, $b, array("cr", "comp_func_cr"), array("cr", "comp_func_key")); print_r($result); ?> The above example will output: Array ( [0.1] => cr Object ( [priv_member:private] => 9 ) [0.5] => cr Object ( [priv_member:private] => 12 ) [0] => cr Object ( [priv_member:private] => 23 ) ) In our example above you see the "1" => new cr(4) pair is present in both arrays and thus it is not in the output from the function. Keep in mind that you have to supply 2 callback functions. NOTES
Note Please note that this function only checks one dimension of a n-dimensional array. Of course you can check deeper dimensions by using, for example, array_udiff_uassoc($array1[0], $array2[0], "data_compare_func", "key_compare_func");. SEE ALSO
array_diff(3), array_diff_assoc(3), array_udiff(3), array_udiff_assoc(3), array_intersect(3), array_intersect_assoc(3), array_uinter- sect(3), array_uintersect_assoc(3), array_uintersect_uassoc(3). PHP Documentation Group ARRAY_UDIFF_UASSOC(3)
All times are GMT -4. The time now is 04:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy