Hi :)
The next script campares two files File1-Line1 vs File2-Line1, File1-Line1 vs File2-Line2... only if line contains "AS-", if LineX is not in File2 writes in aux, but "valor" is allways=1 never changes! :confused: What is wrong?
valor changes to 0 before break, after brake is again 1
... (3 Replies)
How...
can I read input by a user character by cahracter. And assign each character from the string to a variable?
Any help would be greatly appreciated!
Thank you! (1 Reply)
Hi
I am trying to write a function that needs to be able to assign the last run shell command to a variable. The actual command string itself not the exit code of the command.
I am using the bash command recall ability to do this as follows:
alias pb='ps | grep ash' ... (3 Replies)
i have a file in this format
curyymm PRVYYMM CDDMmmYY bddMmmyy eddMmmyy
--------- ------- ------------ ---------- -----------
0906 0905 09Jun09 01Jun09 30Jun09
----------- --------- ------------ ------------ -----------
i need to read the... (5 Replies)
I have a csv file with the values seperated by commas.I want to extract these values one by one and assign to a variable using shell script.Any ideas or code? (11 Replies)
Hi all,
I want write a csh script which must be able:
1.read a file
2.assign value in file as variable
and can i use read in csh script?
thx (2 Replies)
Hi ,I am trying to assign string to variable ,but it doesn't work
Also could you show me different ways to use grep,(I am trying to get the first,second and first column form file,and I am counting the chars)
let name=`grep "$id" product | cut -c6-20` (25 Replies)
Hi,
I have a text file with multiple lines, each having data in the below format <DOB>,<ADDRESS>
I have to write a script which reads each line in the text file in loop, assign the values to these variables and do some further processing in it.
Using the following code prints the values... (12 Replies)
Hello,
I am using below code for reading from a file and assigning the values to a variable , but it is loosing the value after the loop , please suggest to retain the value of the variable after the loop ,
while IFS=: read -r line
do
set $dsc=$line
echo 'printing line variable ' $line... (1 Reply)
Discussion started by: ParthThakkar
1 Replies
LEARN ABOUT PHP
var_export
VAR_EXPORT(3) 1 VAR_EXPORT(3)var_export - Outputs or returns a parsable string representation of a variableSYNOPSIS
mixed var_export (mixed $expression, [bool $return = false])
DESCRIPTION var_export(3) gets structured information about the given variable. It is similar to var_dump(3) with one exception: the returned represen-
tation is valid PHP code.
PARAMETERS
o $expression
- The variable you want to export.
o $return
- If used and set to TRUE, var_export(3) will return the variable representation instead of outputting it.
RETURN VALUES
Returns the variable representation when the $return parameter is used and evaluates to TRUE. Otherwise, this function will return NULL.
NOTES
Note
When the $return parameter is used, this function uses internal output buffering so it cannot be used inside an ob_start(3) callback
function.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.1.0 | |
| | |
| | Possibility to export classes and arrays con- |
| | taining classes using the __set_state() magic |
| | method. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
var_export(3) Examples
<?php
$a = array (1, 2, array ("a", "b", "c"));
var_export($a);
?>
The above example will output:
array (
0 => 1,
1 => 2,
2 =>
array (
0 => 'a',
1 => 'b',
2 => 'c',
),
)
<?php
$b = 3.1;
$v = var_export($b, true);
echo $v;
?>
The above example will output:
3.1
Example #2
Exporting classes since PHP 5.1.0
<?php
class A { public $var; }
$a = new A;
$a->var = 5;
var_export($a);
?>
The above example will output:
A::__set_state(array(
'var' => 5,
))
Example #3
Using __set_state() (since PHP 5.1.0)
<?php
class A
{
public $var1;
public $var2;
public static function __set_state($an_array)
{
$obj = new A;
$obj->var1 = $an_array['var1'];
$obj->var2 = $an_array['var2'];
return $obj;
}
}
$a = new A;
$a->var1 = 5;
$a->var2 = 'foo';
eval('$b = ' . var_export($a, true) . ';'); // $b = A::__set_state(array(
// 'var1' => 5,
// 'var2' => 'foo',
// ));
var_dump($b);
?>
The above example will output:
object(A)#2 (2) {
["var1"]=>
int(5)
["var2"]=>
string(3) "foo"
}
NOTES
Note
Variables of type resource couldn't be exported by this function.
Note
var_export(3) does not handle circular references as it would be close to impossible to generate parsable PHP code for that. If you
want to do something with the full representation of an array or object, use serialize(3).
Warning
When var_export(3) exports objects, the leading backslash is not included in the class name of namespaced classes for maximum com-
patibility.
SEE ALSO print_r(3), serialize(3), var_dump(3).
PHP Documentation Group VAR_EXPORT(3)