Showing posts with label explode php. Show all posts
Showing posts with label explode php. Show all posts
explode php - string to array in php
Posted by Raj
explode php-string to array in php
explode: converts a string into an array.
Syntax
explode(separator,string)
Example:string to array in php
<?php
$str = "A,B,C,D";
print_r (explode(",",$str));
?>
OUTPUT:
Array
(
[0] => A
[1] => B
[2] => C
[3] => D
)
explode: converts a string into an array.
Syntax
explode(separator,string)
Example:string to array in php
<?php
$str = "A,B,C,D";
print_r (explode(",",$str));
?>
OUTPUT:
Array
(
[0] => A
[1] => B
[2] => C
[3] => D
)
PHP explode() Function
Posted by Raj
PHP explode() Function
explode :- The explode() function split a string into an array.
Syntax
explode(separator,string)
Note: Separator cannot be an empty string
Example: explode()
<?php
$name= "PHP implode explode string functions";
$arr = (" ", $name);
print_r($arr);
?>
Output:
array([0]=>"PHP",[1]=>"implode",[2]=>"explode",[3]=>"string",[4]=>"functions");
Ternary conditional operator in PHP?
Posted by Raj
Ternary conditional operator:
Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.
Syntax:
Condition ? value if true :value if false;
Example:
<?php
$id = isset($_POST['name']) ? $_POST['name'] : false;
?>