Click here to Skip to main content
14,932,457 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, php array gets following output:

2020-12-20, 2020-12-24

How can I count the dates which are cut by "," by using ajax?

Output should be: 2

What I have tried:

Read the construct about arrays but i dont work.
Posted
Updated 22-Dec-20 5:29am

1 solution

That doesn't seem like an array at all (in the coding sense) but a comma-delimted list.

Look into the php explode() function to get your answer (and an array) as you can look at the array length and have your answer.
   
Comments
Fynn Pfingsten 22-Dec-20 14:08pm
   
Okay, it is working now. How can I return ajax in h2 tag, in div it is working fine..."
W Balboos, GHB 22-Dec-20 14:13pm
   
That depends a lot upon what you want to do with it.
AJAX returns are always as an ECHO of some string. It would also need a target element for the data or some other use - and that really depends upon what you're doing with the data. See https://www.w3schools.com/js/js_ajax_intro.asp for how to use AJAX - but beyond that

it's really up to you to return the data (as a character string!) in some manner. If you want to return the array then you can use JSON, as well, with the AJAX.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900