To merge duplicate values into multi-dimensional array in PHP, the code is as follows −Example Live DemoOutputThe unique array elements are Array ( [Cycling] => Array ( [0] => Array ( [Age] => 23 [name] => Joe [hobby] => Cycling ) [1] => Array ( [Age] => 30 [name] => Dev [hobby] => Cycling ) ... Read More
The HTML DOM console.trace() method is used to display the stack trace upto the point the console.trace() method has been called upon. It is basically used for displaying the code path i.e how the code ended up at that point.SyntaxFollowing is the syntax for console.trace() method.console.trace(label);Here, label is an optional parameter of type string to specify the label for the code trace. This helps if there are multiple traces for different pieces of code.ExampleLet us look at an example for the console.trace() method − console.trace() Method Click the below button… Start Trace function Function1(){ ... Read More
This example demonstrates how do I programmatically turn on wifi in android device.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javaimport android.content.Context; import android.net.wifi.WifiManager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Toast; public class MainActivity extends AppCompatActivity { private WifiManager wifiManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ... Read More
The HTML DOM input number disabled property returns and modify whether the input field of type=”number” in an HTML document is disabled or not.SyntaxFollowing is the syntax −Returning disabledobject.disabledModifying disabledobject.disabled = true | falseExampleLet us see an example of HTML DOM input number disabled property − Live Demo html{ height:100%; } body{ text-align:center; color:#fff; background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) center/cover no-repeat; background:#B39CD0; height:100%; } p{ font-weight:700; font-size:1.2rem; ... Read More
This example demonstrates how do I customize a button to set text and color in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javaimport android.graphics.Color; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.Button; public class MainActivity extends AppCompatActivity { Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button = findViewById(R.id.customBtn); ... Read More
We can use some logical methods to get the values and also keys from an object, but those methods will not return the values as an array, which is very useful in many cases. Javascript has provided Object.values() method to get an array whose elements are the enumerable property values of an object.syntaxObject.values(obj);This method takes an object as an argument and returns an array whose elements are nothing but the property values of the object.Example-1In the following example, an object is sent through the method object.values() and the property values were displayed as an array.Live Demo var obj = ... Read More
Given array with set of elements and the task is to find out set with exactly three elements having sum less than or equals to k.Input − arr[]= {1, 2, 3, 8, 5, 4}Output − set → {1, 2, 3} {1, 2, 5} {1, 2, 4} {1, 3, 5} {1, 3, 4} {1, 5, 4} {2, 3, 5} {2, 3, 4}In this, first task is to calculate the size of array depending upon which for loop of i is iterated till size-2 and for loop of j is iterated till size-1 and for loop of k is iterated till sizeAlgorithSTART Step 1 ... Read More
The HTML DOM input number name property returns and modify the value of the name attribute of the input field of type=”number” in a HTML document.SyntaxFollowing is the syntax −1. Returning nameobject.name2. Modifying nameobject.name = “text”ExampleLet us see an example of HTML DOM input number name property − Live Demo html{ height:100%; } body{ text-align:center; color:#fff; background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) center/cover no-repeat; height:100%; } p{ font-weight:700; font-size:1.2rem; } ... Read More
The HTML DOM input number readOnly property returns and modify whether the input number field is read-only or not in an HTML document.SyntaxFollowing is the syntax −Returning readOnlyobject.readOnlyModifying readOnlyobject.readOnly = true | falseExampleLet us see an example of input number readOnly property − Live Demo html{ height:100%; } body{ text-align:center; color:#fff; background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) center/cover no-repeat; height:100%; } p{ font-weight:700; font-size:1.1rem; } input{ display:block; ... Read More
The HTML DOM input month value property returns and modify the value of the value attribute of an input month field.SyntaxFollowing is the syntax −Returning valueobject.value2. Modifying valueobject.value = true | falseExampleLet us see an example of HTML DOM input month value property− Live Demo html{ height:100%; } body{ text-align:center; color:#fff; background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) center/cover no-repeat; height:100%; } p{ font-weight:700; font-size:1.1rem; } ... Read More