解压一个字符串 [英] unpack a string
问题描述
我已经使用此函数创建了一个名为$ headers的字符串:
函数GetHeaders($ file_name){
return"< th> < a href =''"。$ file_name。"& order_by = l_e''> L_E< / a>< / th>
< th>< a href =''"。$ file_name。"& order_by = carnumber''> Carnumber< / a>< / th>
< th>< a href ='' "。$ file_name。"& order_by = location''>位置< / a>< / th>
< th>< a href =''"。$ file_name。"& order_by = sighting_date_asc''> Sighting
日期< / a>< / th>
< th>< a href = ''"。$ file_name。"& order_by = classification''> Code< / a>< / th>
< th>< a href =''" ;。$ file_name。"& order_by = railroad''> RR< / a>< / th>
< th>< a href =''"。$ file_name " ORDER_BY =原点 '' >产地< / A>< / th>
< th>< a href =''"。$ file_name。"& order_by = destination''> Destina tion< / a>< /
th>
< th width =''15%''>< a href =''"。$ file_name。"''> ETA< / a>< / th>" ;;
}
现在我要解压缩$ header数组并创建两个字符串,
称为s1和s2。我希望s1是excel的字段名,s2是
是列名。例如,l_e是字段名称,L_E是
,大写为Excel中的列标题。换句话说,我想要
是order_by =之后的两个字段,而不是''和< / a> ;.
如何使用unpack ?
s1 =解包($ header / 37,9,$ data)
我不知道如何使用unpack但是我有$ header数组作为
字符串,我对单词order_by计算了37个字符,单词
order_by =是9个字符我想在之前抓住那个单词''。
我如何利用解包功能来获得我想要的东西?
tia,
I have used this function to create a string called $headers:
function GetHeaders($file_name){
return "<th><a href=''".$file_name."&order_by=l_e''>L_E</a></th>
<th><a href=''".$file_name."&order_by=carnumber''>Carnumber </a></th>
<th><a href=''".$file_name."&order_by=location''>Location</a></th>
<th><a href=''".$file_name."&order_by=sighting_date_asc''>S ighting
Date</a></th>
<th><a href=''".$file_name."&order_by=classification''>Code </a></th>
<th><a href=''".$file_name."&order_by=railroad''>RR</a></th>
<th><a href=''".$file_name."order_by=origin''>Origin</a></th>
<th><a href=''".$file_name."&order_by=destination''>Destina tion</a></
th>
<th width=''15%''><a href=''".$file_name."''>ETA</a></th>";
}
Now I want to unpack the $header array and create two strings,
called s1 and s2. I want s1 to be field names for excel and s2 to
be the column names. For example l_e is the field name and L_E is
capitalized to be the column header in Excel. In other words, I want
is the two fields after the order_by= without the ''and the </a>.
How to use unpack?
s1=unpack($headers/37, 9, $data)
I don''t know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the ''.
How do I make use of the unpack function to get what I want?
tia,
推荐答案
标题:
函数GetHeaders(
headers:
function GetHeaders(
file_name){
return"< th>< a href =''"。
file_name){
return "<th><a href=''".
file_name。"& order_by = l_e''> L_E< / a>< / th> ;
< th>< a href =''"。
file_name."&order_by=l_e''>L_E</a></th>
<th><a href=''".
这篇关于解压一个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!