Skip to content

Tag: php

How do you add custom fonts in TCPDF?

I would like to add a custom font to a pdf I’m generating using TCPDF. I might be missing something but the docs seem to be out dated. They are referencing the addTTFfont() function but I think it’s been deprecated and no longer exists in the latest version of TCPDF. I read that I need to convert …

How to only use created_at in Laravel

I want only use created_at , how to do it? I know: This can custom timestamps name This can disable timestamps Answer Eloquent does not provide such functionality out of the box, but you can create it on your own using the creating event callback:

Replace multiple dashes with one dash

I have a string which looks like this: I want to replace the multiple dashes with a single one. So the expected output would be: I tried to use str_replace(), but I have to write the code again for every possible amount of dashes. So how can I replace any amount of dashes with a single one? For Rizier: Tried:

How to add woocommerce custom order status?

I have added new custom order status to woocommerce by using following function. whenever I go to edit order and changed the order status to newly added custom order status and click on Save Order button. After loading the order status automatically changes to Pending Order not stands in newly added custom or…

readfile downloads an empty file and wrong file type

I am using the code below to download a csv file from a button click. JS: csv.php: download.php: When I execute the function, the file downloaded is download.php despite the correct headers being passed (confirmed via console), the file is also empty. Also when I use print() it prints the CSV data so I know t…