Sponsored Content
Top Forums Web Development Notes with Ravinder on Badging System Development Part II Post 303028310 by Neo on Friday 4th of January 2019 05:21:34 AM
Old 01-04-2019
Ravinder,

Please write a PHP function to parse the $color[] array and create the string(2) to append in the badge alert text.

Hint: You need to read a $serialized_badges JSON string (which we will get from the user table and convert it to a PHP array using json_decode() then perhaps a foreach() loop to compare against the current $color[] array.

Or, you can do all this in Javascript by storing the badge[] js array serialized in localstorage, which is how I would do it I think.... No reason to do this in PHP, so I think best to do in Javascript.
 

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
SERIALIZE(3)								 1							      SERIALIZE(3)

serialize - Generates a storable representation of a value

SYNOPSIS
string serialize (mixed $value) DESCRIPTION
Generates a storable representation of a value. This is useful for storing or passing PHP values around without losing their type and structure. To make the serialized string into a PHP value again, use unserialize(3). PARAMETERS
o $value - The value to be serialized. serialize(3) handles all types, except the resource-type. You can even serialize(3) arrays that con- tain references to itself. Circular references inside the array/object you are serializing will also be stored. Any other refer- ence will be lost. When serializing objects, PHP will attempt to call the member function __sleep() prior to serialization. This is to allow the object to do any last minute clean-up, etc. prior to being serialized. Likewise, when the object is restored using unserialize(3) the __wakeup() member function is called. Note Object's private members have the class name prepended to the member name; protected members have a '*' prepended to the member name. These prepended values have null bytes on either side. RETURN VALUES
Returns a string containing a byte-stream representation of $value that can be stored anywhere. Note that this is a binary string which may include null bytes, and needs to be stored and handled as such. For example, serialize(3) out- put should generally be stored in a BLOB field in a database, rather than a CHAR or TEXT field. EXAMPLES
Example #1 serialize(3) example <?php // $session_data contains a multi-dimensional array with session // information for the current user. We use serialize() to store // it in a database at the end of the request. $conn = odbc_connect("webdb", "php", "chicken"); $stmt = odbc_prepare($conn, "UPDATE sessions SET data = ? WHERE id = ?"); $sqldata = array (serialize($session_data), $_SERVER['PHP_AUTH_USER']); if (!odbc_execute($stmt, $sqldata)) { $stmt = odbc_prepare($conn, "INSERT INTO sessions (id, data) VALUES(?, ?)"); if (!odbc_execute($stmt, $sqldata)) { /* Something went wrong.. */ } } ?> NOTES
Note Note that many built-in PHP objects cannot be serialized. However, those with this ability either implement the Serializable inter- face or the magic __sleep() and __wakeup() methods. If an internal class does not fulfill any of those requirements, it cannot reli- ably be serialized. There are some historical exceptions to the above rule, where some internal objects could be serialized without implementing the interface or exposing the methods. Notably, the ArrayObject prior to PHP 5.2.0. Warning When serialize(3) serializes objects, the leading backslash is not included in the class name of namespaced classes for maximum compatibility. SEE ALSO
unserialize(3), var_export(3), json_encode(3), Serializing Objects, __sleep(), __wakeup(). PHP Documentation Group SERIALIZE(3)
All times are GMT -4. The time now is 07:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy