Unlock the power of PHP with our expert articles. From beginner basics to advanced development techniques, our tutorials will help you build robust and scalable web applications. Explore now!
When creating forms for Magento, it is helpful to know the different types of built-in fields that can be used while creating a form. The below examples can be used to create an admin form by extending the Mage_Adminhtml_Block_Widget_Form block. Hidden Field Text Time Textarea Submit Select Example 1 Example 2 Radio Example 1 Example…
If you have an array that contains a hundred different values, you may be wondering how you can check if that array contains a certain string. As you may already know, you can use the foreach() function to echo out each value contained inside the array. But let’s imagine that we simply want to execute…
If you need to insert a comma separated string into a variable you can accomplish this with the following code. Let’s take a look at our string. We can insert our string into an array by simply using the explode() function. Now if we use the print_r() function we can view our array. We should…
If you find that you have a string that contains commas and you need to remove them you can do the following. Let’s assume your string looks like this. Now let’s strip those ugly commas from our variable $myString using the str_replace() function. That’s it, enjoy!
Counting the elements in an array is quite simple. The $counter variable will now contain the value of 3. However, if your array contains empty values like the following array it would still return 3. This of course would be problematic in some situations of your script. In order to get the accurate count, we…