Convert a string to an array

Tutorials Algorithms Analysis of Algorithms Data Structures Languages Interview Corner GATE ISRO CS UGC NET CS CS Subjects Web Technologies Student Jobs quý khách hàng sẽ xem: How to convert integers to strings và strings to lớn integers in php


Bạn đang xem: Convert a string to an array

*

*



Xem thêm: merge array php

*

*



Xem thêm: Cmc Akamai Là Gì ? Định Nghĩa Cdn Cmc Akamai Cdn Có Nghĩa Là Gì

The strval() function is an inbuilt function in PHP. và is used lớn convert any scalar value (string, integer, or double) to a string. We cannot use strval() on arrays or on object, if applied then this function only returns the type name of the value being converted.

Syntax:

strval( $variable ) Parameter: This function accepts a single parameter $variable. This parameter represents the value which we want to convert khổng lồ string

Return value: This function returns a string. This string is generated by typecasting the value of the variable passed to lớn it as a parameter.

Below programs illustrate the strval() function.

Program 1:

$var_name = 32.360; // prints the value of above sầu variable // as a string eđến strval($var_name); ?>

Output:

32.36Program 2:

class darkedeneurope.com public function __toString() // returns the class name return __CLASS__; // prints the name of above sầu class as // a string emang đến strval(new darkedeneurope.com); ?>

Output:

darkedeneurope.comProgram 3:

// Program khổng lồ illustrate the strval() function // when an array is passed as parameter // Input array $arr = array(1,2,3,4,5); // This will print only the type of value // being converted i.e. "Array" eđến strval($arr); ?>

Reference:http://php.net/manual/en/function.strval.php

*

darkedeneurope.com Vote for difficulty Easy Normal Medium Hard Expert Improved By : Report Issue What’s NewData Structures and Algorithms – Self Paced CourseView DetailsAd-Free Experience – darkedeneurope.com PremiumView DetailsMost popular in PHPMost visited in Web Technologies

Writing code in comment? Please use ide.darkedeneurope.com, generate liên kết & tóm tắt the links here.


Chuyên mục: