H2S64: Parsing: The interchange of stringed information and programming information

Hu, x-ref: WP-Buffalo: Starting to use p-dash to organize my links, for example, right now I’m studying WebSockets API to build real.time-messaging. How can I build a simple checkbox feature, that allows users to specify the HTML target attribute to either 1) open in a new window, or 2) open in the same tab? There would be a 3rd input column, in this screen capture, where users can check, for each row, the target, and the column name would be “New-tab”

From my notes:

/* I need to implement # a checkbox as the 3rd input, for each line, to determine link target; however, I'm not willing to add 9 new columns, to my table. Therefore, the link target property should be stored in the URL field itself, as a tag. Another option is to add a single column for "attributes", which will contain settings that can be searched and applied to all columns. In this column, I can store some data like: url1="_blank";url2="_blank";url5="_blank" Modelled after CSS in.line-styling: style="color:blue;text-align:center;" https://www.w3schools.com/css/css_howto.asp The attributes column will be retrieved as a string, at the beginning of both post.post-# and dash-edit, and propagated down # to each column data, in which the attribute can be applied. */

Hu: So here, I think we have a fundamental comp.sci-problem: parsing. I am storing a bunch of attributes, in the style of CSS.in-line, as a string, in the db. When this string is retrieved, in order to compose pages as HTML, it needs to be “unpacked”, and the attributes need to be re-associated with each individual element. On the other side, there is a “zipping” function that gathers all the attribute inputs and “zips” them into a string, so this is like a very unit version of a program like WinZip.

H3S1: Implementing str_split():

Ref: <WP.MIC-H2S35> Attributes solution: how do I loop through the attribute string, in order to read it, as an array? I need to generate an array based on the string, that is an associative array, with named keys, that a function can process, to return=>echo<fbno> “_blank”, and this function will be called, inside target=””, in the loop, in the <a href> tag, for each url instance #, with a parameter that is variable-updated in the loop.

I need to write a function that takes $_GET[‘author’] and $_GET[‘post_ID’] as inputs, SELECTS the attributes string for that row, runs str_split(), and smart-processes the resulting array, looping through it, in order to add to a resulting associative array, where url$x is the key, and the target attribute is the value.

Secondly, I need another function that loops through the resulting array, which has a higher language level, that is called, in-line, by each URL, that takes url$x as a parameter, determined by the loop, and returns either the _blank attribute.

Both functions will be defined in mysql-inc; one function is called one time, before for loop table gen, and the second function is called every loop<9x>. The 9x recursion of p-dash gives rise to unique function design, and possibilities, like chess

A second conditional is needed to cut within ;;, to read =, and what is left, the key, what is right, the value.

H3S2: Double.array-str<Turing>:

Hu: The array generated by the first function call will be stored in the server side document and passed as an argument, along with the specific field to search for, in the second function call. Do this one in separate docs, to start. Read <WP.MIC-H2S60,H3S3>for looping through an array #

Hu<WP.Buffalo-10,26>And here we go: I have invented a function, attributes_parse( that will take an attributes string, which I generated with my compiler # earlier, and output an associative array, with 9 key.value-pairs. The function uses a custom segmentation, when “;” is landed upon, to bulk the pairs, and then splits the pairs, with strtok()<H3S3-H4S1>, before assigning the key and value, to a resulting assoc_array, that the function returns.

Code-output<fbno>: Array ( [url1] => _blank [url2] => _blank [url3] => _blank [url4] => _blank [url5] => _blank [url6] => _blank [url7] => _blank [url8] => _blank [url9] => _blank )

By swapping out the “;” and “=” chars, you can set your own split-chars, at each level. This function can also be infinitely recursive to handle parsing at an infinite level of categorization<Turing>

$attributes = 'url1=_blank;url2=_blank;url3=_blank;url4=_blank;url5=_blank;url6=_blank;url7=_blank;url8=_blank;url9=_blank;'; 
function attributes_parse($attributes) {
	$attributes_char_array = str_split($attributes); 
	$pair = '';
	foreach($attributes_char_array as $char) {
		// If can be rephrased as "when you reach"...
		if ($char == ';') {
			$key = strtok($pair, "=");
			$value = strtok("=");
			$attributes_assoc_array[$key] = $value;
			$pair = '';
		} else {
			$pair = $pair . $char; 
	return $attributes_assoc_array;
$attributes_assoc_array = attributes_parse($attributes);

Hu: Returning the settings as an assoc_array, as a discrete function, allows the settings to be applied differentially, in case there are different manifestations of the same tb-row, as pages. For example, websites may have a different “display-page”, and “edit-page”, both referring to the same row<Turing>

H3S3: Str.pars-functions,lib.PHP<Turing>:

H4S1: strtok()<search!>

W3: The strtok() function splits a string into smaller | strings (tokens).

stringRequired. Specifies the string to split
splitRequired. Specifies one or more split characters

W3: In the example below, note that it is only the first call to strtok() that uses the string argument. After the first call, this function only needs the split argument, as it keeps track of where it is in the current string. To tokenize a new string, call strtok() with the string argument again:

$pair = 'url1=_blank';
$key = strtok($pair, "=");
$value = strtok("=");
echo $key . '<br>';
echo $value;


Hu: Line by line<Turing>: line 1 defines the string, and assigns it the name $string. Line 2 creates a variable, $key, that represents a string | segment. In this definition, the split | character is defined as ” “, or an empty | space. The first run of strtok will take all the chars, as a string, before “=” is reached, and assign it, as a string, to $key. Subsequently, strtok(), in a pseudo-session<Turing>, stores the remaining string, such that when it is called again, to generate $value, it will pack the next segment, either until “=” or null is reached, which means $value will be assigned the remaining chars, _blank.

<php.net>: Every subsequent call to strtok only needs the token to use, as it keeps track of where it is in the current string. To start over, or to tokenize a new string you simply call strtok with the string argument again to initialize it. Note that you may put multiple tokens in the token parameter. 

H4S2: Forcing-seq(!!) -5.6 w/ ~7 o-n at d.15-s in atypical 8. c5 Indian-🛡️<fbno>

Ref: <MIC-H2S11>

15…Nxd4 -5.6 16. Qxd4 h6 17. Bf4 Nd7$.c5-P<3 o-n> 18. Qa4 Nxc5 19. Qxa7 g5$ 20. Be3 d4 21. Rad1 Bb3$.d1-R 22. Rd2 f5!


H4S3: W3: substr_replace() replaces a part of a string with another string<search!>

H4S4: W3: The substr() function returns a part of a string. Hu: by length.

<php.net>: If length is omitted or null, the substring starting from offset until the end of the string will be returned. If offset is non-negative, the returned string will start at the offset‘th position in string, counting from zero. For instance, in the string ‘abcdef‘, the character at position 0 is ‘a‘, the character at position 2 is ‘c‘, and so forth. If offset is negative, the returned string will start at the offset‘th character from the end of string.

substr(string $string, int $offset, ?int $length = null): string

H4S5: strrchr()<search>

W3: The strrchr() function finds the position of the last occurrence of a string within another string, and returns all characters from this position to the end of the string. Hu: This function is half of strtok(), and returns the second half #

H5S1: W3: The strstr() function searches for the first occurrence of a string inside another string.

H5S2: W3: The strchr() function searches for the first occurrence of a string inside another string.

H4S6: W3: The strrev() function reverses a string.

H4S7: strrpos()


  • strpos() – Finds the position of the first occurrence of a string inside another string (case-sensitive) <php.net>: strpos(string $haystack, string $needle, int $offset = 0): int|false Find the numeric position of the first occurrence of needle in the haystack string.
  • stripos() – Finds the position of the first occurrence of a string inside another string (case-insensitive)
  • strripos() – Finds the position of the last occurrence of a string inside another string (case-insensitive)

H4S8: strpbrk()

W3: The strpbrk() function searches a string for any of the specified characters.

H4S9: str_contains()

<php.net>: Determine if a string contains a given substring. Performs a case-sensitive check indicating if needle is contained in haystack

str_contains(string $haystack, string $needle): bool

H4S10: strtolower()

<php.net>: Returns string with all alphabetic characters converted to lowercase.

strtolower(string $string): string

H3S4: Array.pars-func,lib:

H4S1: array_search()

<php.net>: Searches the array for a given value and returns the first corresponding key if successful.

array_search(mixed $needle, array $haystack, bool $strict = false): int|string|false

<php.net, languages.types.declarations>: mixed is equivalent to the union type object|resource|array|string|int|float|bool|null. Available as of PHP 8.0.0. needle: The searched | value. Note: If needle is a string, the comparison is done in a case-sensitive | manner. strict If the third parameter strict is set to true then the array_search() function will search for identical elements in the haystack. This means it will also perform a strict type comparison of the needle in the haystack, and objects must be the same instance. Returns the key for needle if it is found in the array, false otherwise. If needle is found in haystack more than once, the first | matching key is returned. To return the keys for all matching values, use H5S1: array_keys() with the optional search_value parameter instead.

H4S2: array_unique — Removes duplicate values from an array.

H4S3: array_uintersect — Computes the intersection of arrays, compares data by a callback function

H5S1: array_intersect_key — Computes the intersection of arrays using keys for comparison

H4S4: sort — Sort an array in ascending order

H4S5: array_flip — Exchanges all keys with their associated values in an array

H4S6: Key.search-return,value:

Hu: There is no built.in-array,function for this, even though it has a function’s operation. This built.in-implicit,function<Turing> is the inverse of H4S1, but without a default return false, since it’s not a function-call, possibly, and therefore, it alone, can cause a null.output-err<WP.MIC-H261,H3S1.H4S2>

H4S7: array_combine — Creates an array by using one array for keys and another for its values.

H3S5: Browser parsing JS:

<Lengstorf, Leggetter pg-23>: JavaScript is loaded into the HTML markup using a <script> tag, which can be parsed by the browser.

H3S6: Concatenation.PHP-lib:

H4S1: Implode:

<php.net> Returns a string containing a string | representation of all the array elements in the same order, with the separator string between each element.

implode(string $separator, array $array): string

H3S7: Str.pars-functions,lib.JS:

// <a-r>





H3S3: Str.pars-func:















H3S3: Array.pars-func:



H3S4: JS-parse:

Realtime Web Apps by Lengstorf and Leggetter, via Apress.

H3S5: Concatenation:









Leave a Reply

Your email address will not be published. Required fields are marked *