Skip to main content

Posts

PHP/Regex - Capturing foreign languages with \p{L} returns Ø [duplicate]

I want to capture any language letters with \p{L} But the problem is it's not working correctly with foreign languages, For example: $a = '/submit /الایمان'; preg_match('~/submit /(\p{L}+)~', $a, $m); echo $m[1]; The above result will return b"Ø" source https://stackoverflow.com/questions/68184315/php-regex-capturing-foreign-languages-with-pl-returns-%c3%98

How to send HTML emails with php

I have made an email template using html and now I want to use it in an actual email using php. I tried using `file_get_contents(); but it does not work. It send the code and not the output. here's how the email looks when I send it I want a way that I can send the html email template I made using php, and if that's not possible what do you guys recommend? source https://stackoverflow.com/questions/68184313/how-to-send-html-emails-with-php

How can i develop a search engine for a website using php and mysql?

So, i need to make a search engine for a website i'm developing, but i don't want anything like an index page. I wanna be able to search from the home page of the website for any title at any page of de website. Can someone please indicate me any material about it or give an idea of how can i do it? source https://stackoverflow.com/questions/68184281/how-can-i-develop-a-search-engine-for-a-website-using-php-and-mysql

saving each sorting step of a quicksort function in an array

I'm trying to understand sorting algorithms and recursion better. Therefore I'm trying to write different sorting algorithms and save each step of the sorting in an array, so I can do some visualization with the saved data. I came up with the following function to implement quicksort. It looks much different than most of the examples I've seen. But to my undertanding it is still a way of quicksort, it definitely returns the sorted array. Please correct me if I'm wrong: const quickSort = (array) => { if (!array.length) return array; const pivot = array.splice( Math.floor(Math.random() * (array.length)), 1 )[0]; const less = []; const greater = []; while (array.length) { const x = array.splice(0, 1)[0]; x < pivot ? less.push(x) : greater.push(x); } return quickSort(less).concat(pivot, quickSort(greater)) } I changed the function in the following way, so I can save the entire array after each sorting step in another array: const steps...

Question about calling async function inside another function

For example for my api call I got this function async function signUp(params) { await api..call } then In my component I call this form submit function const submit = async (info) => { } should I still call it as await.signUp(info) inside the submit function or await is not needed here because the original function is async / await? How should this look properly? Maybe async await is not needed anymore if the signUp function is async? Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

React state update (SWR) and component refresh?

I'm using SWR to fetch data as stated in the docs : function App () { const [pageIndex, setPageIndex] = useState(0); // The API URL includes the page index, which is a React state. const { data } = useSWR(`/api/data?page=${pageIndex}`, fetcher); // ... handle loading and error states return <div> {data.map(item => <div key={item.id}>{item.name}</div>)} <button onClick={() => setPageIndex(pageIndex - 1)}>Previous</button> <button onClick={() => setPageIndex(pageIndex + 1)}>Next</button> </div> } The only difference in my case is I'm loading more items on the same page (so more like infinite scroll not pagination), but here's the trouble: const { data } = useSWR(`/api/data?page=${pageIndex}`, fetcher); Notice how data is fetched based on pageIndex variable, that comes from the state. Once it changes everything rerenders, so instead of getting more items every time user clicks on a button ...

Vuejs website wont run on mobile but will run on a PC

I made a website in Vuejs, and it works great on PC. I tested it in Chrome, Firefox, and Edge. In all browsers work without problems. But if i try to load the website on a IPad or Iphone - all i get is a empty page, vuejs is not even running - just a empty page. I already added transpiling for node modules but still not working on mobile. I cant share the code of my website here (too big, private source) but im hoping someone else had this same problem and can point me in the right direction. I use @vue/cli 4.5.13 with webpack. I am trying for over a week now and i cant seem to find what is wrong.. Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW