Author

Admin

Browsing

Today, We are going to learn PHP remove HTML tags from a string. We can remove HTML tags from the string using two ways. First, PHP provides the strip_tags function for removing HTML tags and preg_replace function for removing HTML tags from a string, Today, We learn both functions with the example.

  • Remove HTML tags using strip_tags function
  • Remove HTML tags using preg_replace function

PHP remove HTML tags from a string

We are going to learn the first example using strip_tags function.

Remove HTML tags using strip_tags function

We are using the strip_tags function for removing the HTML tags from the string. So, it’s very easy to remove HTML tags from a string. But the “strip_tags” add space after removing the tags from the string like.

The output of the above statement is “Hello world!” instead of “Helloworld!”.

So, let’s see the second example for removing HTML tags from a string and get the output like “Helloworld!” instead of “Hello world!”.

Remove HTML tags using preg_replace function

The output of the above function is “Helloworld!” instead of “Hello world!”.

We check the both function with the example Now, choose the which function is helpful for you and use it for removing HTML tags from a string.

If you face any issue after using above code please write the comment below.

Today, We are going to learn programmatically PHP create ZIP file. PHP provides ZipArchive class using that we can easily create the zip file. But Today, I am going to share function with you using that function you can easily create the ZIP file by passing the directory name or file name.

Suddenly, My client tells me to move his project from one server to another server and his use the shared hosting. So, I have only FTP detail at that time I created “createZip” function for creating the zip file of files or directories. I am going to share that function with you So, you can easily create the zip file without hard work using PHP. You just need to write single line code for PHP creating ZIP file.

PHP create ZIP file

Just past the “createZip” function anywhere on your project then you just need to call that function for creating the zip file like

If you need to create the zip file of the current directory then you need to pass dot except for the directory path like

Or else you should pass the full directory path like

After, Creating the ZIP file if you want to move it another server without download it on your local system then You can follow my tutorial “Download Archive file from URL

If you face any issue after using this code please write the comment below.

Today, We are going to learn how to Download zip file from URL using PHP. PHP download archive file using single line of code. We can easily download the any file using PHP single line of code. We use file_put_contents for download file.

PHP Download Archive file

You can download any types of file using this function like JPG, JPEG, EXE, PNG, MP4, MP3 etc…

This trick is very useful when you want to move project to new server. We don’t need to download project to local system and then upload it to new server. Just create zip file of the project and create PHP script to new server then directly download project file on new server using PHP script.

If you face any problem after using this code please write a comment.

Today, We are going to learn how to find the records between two different numbers like find the product that price is between 5 to 25. So, Let’s see how we can find the records between two numbers. MySQL between two numbers in Laravel. We can find the records between two numbers using two ways in Laravel. Let’s see the first way how we can find the records between two numbers.

MySQL between two numbers in Laravel

You can achieve the same result using less than and greater than instead of whereBetween function. let’s see the second way for finding the records.

You can achieve the same result on the both example. So, it’s too easy to find the product between two number.

If you face any issue after using this query please write the comment below.

Today, We are going to learn how we can find the number between two columns in Laravel. Many times we need to find the number between two columns like from and to. Laravel allows us to write complex MySQL query using DB RAW. Let’s how we can write the query for MySQL BETWEEN Two Columns in Laravel.

MySQL BETWEEN Two Columns in Laravel

Just follow the query for finding the number between two columns.

Also, We can find the number between two column using another way like.

Both queries are working fine with Laravel for finding the number between two columns. I hope the article is helpful to you.

If you face any issue after following the query please write the comment.

By default, WordPress does not allow to add shortcodes in the widget. If you want to enable shortcode functionality for Widget then you need to allow shortcode for widget text. So let’s see how to enable shortcodes in WordPress widget. it’s too easy to allow shortcode in a widget. just follow below steps.

Enable Shortcodes in WordPress widget

Open functions.php  From of your current WordPress theme. Then add the below code at the end of the file.

Now add shortcodes as you want on the widget. The shortcodes are working on Widget.

If you face any issue after adding this code then please write the comment.

Many times we get the jQuery is not defined error in WordPress. We got this error because the jQuery is a conflict with another plugins or theme. We face the jQuery is not defined error in some WordPress site. The same code is working on some other WordPress website. So, How we can solve WordPress jQuery is not defined issue by a single line of code.

WordPress jQuery is Not Defined

Whenever you need to written jQuery code in WordPress. You must follow the jQuery noConflict syntax. If you write your code using jQuery noConflict syntax. Then you never get the jQuery is not defined or $ is not defined error. Your jQuery code is working fine on every WordPress sites.

Write the jQuery code with WordPress jQuery noConflict syntax.

So, Write your jQuery code using the above syntax. I hope that code is useful for you.

If you face any issue after using the above code please write the comment below.

We are going to discuss How to properly use jQuery noConflict mode in WordPress. Because Many times we face or jQuery not found an issue in WordPress. So, Today we are going to learn how to write the jQuery code in WordPress.

jQuery noConflict mode in WordPress

So whenever you need to write the jQuery code in WordPress then you should follow the jQuery noConflict syntax. Just follow the below code for writing jQuery noConflict mode syntax.

 

Now, you can write the jQuery code using $ and jQuery. Now you don’t get the $ or jQuery is not defined error on console.

Still, If you face any issue on jQuery in WordPress please write the comment below.

Today, We are going to learn How to create Category tree from Array using PHP. Many times we need to create the parent and child category tree. Let’s make it easy with a single function. Yes, You can create the parent and child tree from Array using a single PHP function. Let’s follow the function and pass Array for creating parent and child category tree.

Category tree from Array

Finally, Our function is ready Now, you just need to pass the category array-like.

Now, let’s pass this Array to buildTree then check the output.

We got output something like below.

So, Our category tree is ready with parent and child hierarchy.

If you face any issue after using this code please write a comment.

Laravel is the fastest growing PHP Framework and Object-oriented framework and provides a rich library. Laravel provides a best validation library using that we can easily validate the incoming request. Today, We are going to learn about the unique validation of Laravel. Laravel unique validation is preventing from the duplicate value on the database. You can easily check the record is exists on the database or not? Using Laravel unique validation. Many times we need set the unique validation for Email, Phone, Slug, SKU etc…

Laravel unique validation

So let’s see how we can use Laravel unique validation. I want to set the unique validation on the slug field then let’s follow the validation rule.

We set the unique validation on slug field. Slug field is very useful when we are working with Blog, Product etc… module. Now, Laravel check for the slug on the database that the slug exists or not? If the slug exists then Laravel fire validation like”The slug has already existed”. So, it’s too easy to set unique validation on Laravel.

Now, Let’s write the unique validation for edit record. We need to change the validation value when we are working on edit functionality. We need to pass the current active record ID as a parameter on validation. Now, Let’s change the unique validation during edit functionality like.

Now, Let’s assume I want to edit the 7 number product then Laravel fire unique validation query like below.

select * from product where slug = ‘simple-product’ and id <> 7;

Now, Check the unique validation working perfectly with edit record functionality.

If you face any issue on Laravel unique validation please write the comment below.