I have a big issue right now in using php foreach function.
(我现在在使用php foreach函数时遇到了一个大问题。)
I need to return each name plus each value from the html source code below or a similar one.
(我需要从下面的html源代码或类似的源代码中返回每个名称加上每个值。)
Example: {_pn_Brand:Dell}. (示例:{_ pn_Brand:Dell}。)
Everything good so far. (到目前为止一切都很好。)
My problem is that the source code contains one or more parameters (in my example below: _pn_Hardware Connectivity, _pn_Features) which can be found several times in the source code and I only need to return the checked ones.
(我的问题是源代码包含一个或多个参数(在下面的示例中为_pn_Hardware Connectivity和_pn_Features),这些参数可以在源代码中多次找到,而我只需要返回选中的参数即可。)
To be more specific I need to return something like: {_pn_Hardware Connectivity:HDMI,USB 2.0}, {_pn_Features:Backlit Keyboard,Bluetooth,Built-in Microphone,Built-in Webcam}.
(具体来说,我需要返回以下内容:{_pn_Hardware Connectivity:HDMI,USB 2.0},{_ pn_Features:Backlight Keyboard,Bluetooth,内置麦克风,内置摄像头}。)
Please keep in mind that the attributes names like _pn_Hardware Connectivity or _pn_Features can change in other source codes so I need a foreach function to generally solve my problem.
(请记住,诸如_pn_Hardware Connectivity或_pn_Features之类的属性名称可以在其他源代码中更改,因此我需要一个foreach函数来普遍解决我的问题。)
I hope you guys understand exactly what I'm looking for.
(我希望你们能完全理解我在寻找什么。)
My apologise for the poor explanation but couldn't think of a better one for the moment. (对于抱歉的解释,我深表歉意,但暂时无法想到更好的解释。)
Please check the html source code below: (请检查以下html源代码:)
<input type="text" name="_pn_Brand" size="21" maxlength="50" gname="Brand" value="Dell">
<input type="text" name="_pn_MPN" size="21" maxlength="50" value="">
<input type="text" name="_pn_Type" size="21" maxlength="50" value="Notebook/Laptop">
<input type="text" name="_pn_Screen Size" size="21" maxlength="50" value="17 in">
<input type="text" name="_pn_RAM Size" size="21" maxlength="50" value="16 GB">
<input type="text" name="_pn_Processor" size="21" maxlength="50" value="Intel Core i7 4th Gen Quad core.">
<input type="text" name="_pn_Graphics Processing Type" size="21" maxlength="50" value="Dedicated Graphics">
<input type="text" name="_pn_Manufacturer Colour" size="21" maxlength="50" value="Black">
<input type="text" name="_pn_Manufacturer warranty" size="21" maxlength="50" value="None" closed="true">
<input type="text" name="_pn_Processor Speed" size="21" maxlength="50" value="2.50- 3.20 GHz">
<input type="text" name="_pn_pnorage Type" size="21" maxlength="50" value="HDD (Hard Disk Drive)">
<input type="text" name="_pn_Hard Drive Capacity" size="21" maxlength="50" value="500 GB">
<input type="text" name="_pn_Operating System" size="21" maxlength="50" value="Windows 10">
<input type="text" name="_pn_Operating System Edition" size="21" maxlength="50" value="Professional">
<input type="text" name="_pn_Release Year" size="21" maxlength="50" value="2014">
<input type="text" name="_pn_Colour" size="21" maxlength="50" value="Black">
<input type="checkbox" name="_pn_Hardware Connectivity" value="DisplayPort">
<input type="checkbox" name="_pn_Hardware Connectivity" value="Mini DisplayPort">
<input type="checkbox" name="_pn_Hardware Connectivity" value="HDMI" checked="checked">
<input type="checkbox" name="_pn_Hardware Connectivity" value="Micro-HDMI">
<input type="checkbox" name="_pn_Hardware Connectivity" value="Micro-USB">
<input type="checkbox" name="_pn_Hardware Connectivity" value="Mini-USB">
<input type="checkbox" name="_pn_Hardware Connectivity" value="USB 1.0/1.1">
<input type="checkbox" name="_pn_Hardware Connectivity" value="USB 2.0" checked="checked">
<input type="checkbox" name="_pn_Hardware Connectivity" value="USB 3.0">
<input type="checkbox" name="_pn_Hardware Connectivity" value="USB 3.1">
<input type="checkbox" name="_pn_Features" value="10/100 LAN Card">
<input type="checkbox" name="_pn_Features" value="3D Camera">
<input type="checkbox" name="_pn_Features" value="Backlit Keyboard" checked="checked">
<input type="checkbox" name="_pn_Features" value="Bluetooth" checked="checked">
<input type="checkbox" name="_pn_Features" value="Built-in Microphone" checked="checked">
<input type="checkbox" name="_pn_Features" value="Built-in Webcam" checked="checked">
<input type="checkbox" name="_pn_Features" value="HSDPA">
<input type="checkbox" name="_pn_Features" value="Tablet PC">
<input type="checkbox" name="_pn_Features" value="Touchscreen">
<input type="checkbox" name="_pn_Features" value="Virtual Reality Ready">
Thanks to everyone that can help in advance!
(感谢每个可以提前帮助的人!)
ask by Iain translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…