Step 1 - Create a PHP page that reads the string (Raw form) in the database, save to a variable (Ex.: $datas
) and "return" that string.
Note: The "return" I’m talking about is NOT done with return $datas
, but rather with echo $datas
, because thus the "return" of the page can be received by the person who made the request (in this case, AJAX).
Step 2 - Create a Javascript function (Preferably using Jquery) that requests the PHP page you created. When you mount the AJAX request, you will have to pass a callback function that will be responsible for handling the request response (The response that PHP will return with echo $datas
).
Step 3 - In the callback function you created in step 2, finally you will have a string (Ex.: datas
) with the dates in the raw format. Here you will use the function split
(Which is applicable to strings) to break the string and save the result to an array. The function split
separates the string into several pieces, so that this separation is controlled by the parameter you pass (Learn more about the split here).
Ex. 1:
var datas = "O rato roeu a roupa"
var vetor = datas.split(" "); // Separa o conteúdo de ***datas*** usando ***espaço***
// vetor = {"O", "rato", "roeu", "a", "roupa"}
Ex. 2:
var datas = "O rato roeu a roupa"
var vetor = datas.split("a"); // Separa o conteúdo de ***datas*** usando ***a***
// vetor = {"O r", "to roeu ", " roupa"}
I don’t know your level of knowledge, and the things I put up, I don’t know what you know. Therefore, I may have been very wordy and I may have written unnecessary things (which would be good, because it would be a sign that you already know) or I may have been very superficial and not explained each thing very well. Anyway, if the second hypothesis is true, I advise you to make a reply listing all the points you did not understand and/or do not know how to do. It’ll make it easier for the guys to help you.
Blood disease
Helpnext
Do you want to extract the dice from the string? It would be that that you need?
– gato
The string in the database contains a list of holidays in the example format "20171012 20171102 20171115 20171120 20171225". Hence I wanted to extract each date from this and put in a variable array.
– Marco Duarte
I put an example in the link above, uses the
explode(' ', $str);
and returns an array. See if it solves the problem.– gato
Sorry, true, now that I’ve seen your Link ... would be just that, only in Ubuntu bash script.
– Marco Duarte
I’m sorry, I answered in the wrong tag, PHP rsrs
– gato
Marco I edited the answer, see there.
– gato
opa !! I saw your answer below, and it was perfect !!! it was that !! thank you very much!
– Marco Duarte