略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: wddx_add_vars

2024-11-14

wddx_add_vars

(PHP 4, PHP 5, PHP 7)

wddx_add_varsAdd variables to a WDDX packet with the specified ID

警告

该函数已在 PHP 7.4.0 中 移除

说明

wddx_add_vars(resource $packet_id, mixed $var_name, mixed ...$var_names): bool

Serializes the passed variables and add the result to the given packet.

参数

This function takes a variable number of parameters.

packet_id

A WDDX packet, returned by wddx_packet_start().

var_name

Can be either a string naming a variable or an array containing strings naming the variables or another array, etc.

var_names

返回值

成功时返回 true, 或者在失败时返回 false

add a noteadd a note

User Contributed Notes 1 note

up
0
maciek at webenlinea dot com
17 years ago
Here is a simple way of serializing dynamic values from an array:

<?PHP
//a unix timestamp
$date    = "1094095513";

//some data to be included
$books   = array('programming'   => array('php','perl','java'),
               
'markup'        => array('UML','XML','HTML')
                );

//stick data to an array to iterate over
$data_to_serialize = array($date,$books);

//create the packet
$packet = wddx_packet_start("SOME DATA ARRAY");

//loop through the data
foreach($data_to_serialize as $key => $data)
{
 
//create a var whith the name of the content of $key
 
$$key = $data;
 
wddx_add_vars($packet,$key);
}

echo
wddx_packet_end($packet);

?>

Have fun !

官方地址:https://www.php.net/manual/en/function.wddx-add-vars.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3