<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Da stringa a float - (float) e floatval non funzionano]]></title><description><![CDATA[<p dir="auto">Come da titolo.<br />
Sono ore che provo a capire perché questo codice apparentemente semplicissimo non funziona.<br />
Prima il codice che uso e sotto il risultato del codice.</p>
<h1>=============================<br />
echo "totale=".$totale;<br />
$totale = explode ('(', $totale);<br />
echo "explode=".$totale[0];<br />
$totale = str_replace('€','',$totale[0]);<br />
echo "&lt;br&gt;str_replace=".$totale;<br />
$totale = substr($totale,0,-1);<br />
echo "&lt;br&gt;substr=".$totale;<br />
$totale = floatval($totale);<br />
echo "&lt;br&gt;floatval=".$totale;</h1>
<p dir="auto">totale=147,00? (Include 26,51? IVA)<br />
explode=147,00?<br />
str_replace=147,00<br />
substr=147,00<br />
floatval=0</p>
<p dir="auto">Spero che sappiate darmi una mano perché io sto uscendo di testa <img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/customizations/f71a0c43-865f-4388-9868-8b387eebeeb1-mmmm.gif?v=12b9555a9a1" class="not-responsive emoji emoji-customizations emoji--mmm" style="height:1.4em;width:auto;vertical-align:middle" title=":?" alt="" /></p>
]]></description><link>https://dev.connect.gt/topic/221594/da-stringa-a-float-float-e-floatval-non-funzionano</link><generator>RSS for Node</generator><lastBuildDate>Thu, 26 Nov 2026 01:02:43 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/221594.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 04 Mar 2016 19:24:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Da stringa a float - (float) e floatval non funzionano on Sat, 05 Mar 2016 12:33:35 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto"><strong>ottomasi</strong></p>
<p dir="auto">Ho risolto!<br />
In realtà quella stringa aveva al suo interno un bel po' di codice html e di conseguenza si incartava tutto!<br />
Grazie mille per l'aiuto!</p>
</blockquote>
<p dir="auto">Infatti te lo stavo per scrivere di fare un output encoddato in qualcosa per vedere se ci fosse altro di mezzo, meglio così <img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=12b9555a9a1" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://dev.connect.gt/post/1218448</link><guid isPermaLink="true">https://dev.connect.gt/post/1218448</guid><dc:creator><![CDATA[bacca001]]></dc:creator><pubDate>Sat, 05 Mar 2016 12:33:35 GMT</pubDate></item><item><title><![CDATA[Reply to Da stringa a float - (float) e floatval non funzionano on Sat, 05 Mar 2016 10:04:41 GMT]]></title><description><![CDATA[<p dir="auto">Ho risolto!<br />
In realtà quella stringa aveva al suo interno un bel po' di codice html e di conseguenza si incartava tutto!<br />
Grazie mille per l'aiuto!</p>
]]></description><link>https://dev.connect.gt/post/1218453</link><guid isPermaLink="true">https://dev.connect.gt/post/1218453</guid><dc:creator><![CDATA[ottomasi]]></dc:creator><pubDate>Sat, 05 Mar 2016 10:04:41 GMT</pubDate></item><item><title><![CDATA[Reply to Da stringa a float - (float) e floatval non funzionano on Sat, 05 Mar 2016 09:26:25 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto"><strong>Bacca001</strong></p>
<p dir="auto">Figurati, se hai bisogno ancora chiedi pure <img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=12b9555a9a1" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
</blockquote>
<p dir="auto">Ora sono da chiavetta e non prende un granché e non posso usare Skype.<br />
Se ti può aiutare posso girarti il codice completo della pagina.</p>
<p dir="auto">Le classi che chiama dovrebbero essere tutte quelle di woocommerce.</p>
<pre><code class="language-php">&lt;?php
/**
 * Print order content. Copy this file to your themes
 * directory /woocommerce/print-order to customize it.
 *
 * @package WooCommerce Print Invoice &amp; Delivery Note/Templates
 */


if ( !defined( 'ABSPATH' ) ) exit;
?&gt;


                &lt;div class="order-branding"&gt;
                    &lt;div class="company-logo"&gt;
                        &lt;?php if( wcdn_get_company_logo_id() ) : ?&gt;&lt;?php wcdn_company_logo(); ?&gt;&lt;?php endif; ?&gt;
                    &lt;/div&gt;
                    
                    &lt;div class="company-info"&gt;
                        &lt;?php if( !wcdn_get_company_logo_id() ) : ?&gt;&lt;h1 class="company-name"&gt;&lt;?php wcdn_company_name(); ?&gt;&lt;/h1&gt;&lt;?php endif; ?&gt;
                        &lt;div class="company-address"&gt;&lt;?php wcdn_company_info(); ?&gt;&lt;/div&gt;
                    &lt;/div&gt;
                    
                    &lt;?php do_action( 'wcdn_after_branding', $order ); ?&gt;
                &lt;/div&gt;&lt;!-- .order-branding --&gt;




                &lt;div class="order-addresses&lt;?php if( !wcdn_has_shipping_address( $order ) ) : ?&gt; no-shipping-address&lt;?php endif; ?&gt;"&gt;
                    &lt;div class="billing-address"&gt;
                        &lt;h3&gt;&lt;?php _e( 'Billing Address', 'woocommerce-delivery-notes' ); ?&gt;&lt;/h3&gt;
                        &lt;address&gt;
                            
                            &lt;?php if( !$order-&gt;get_formatted_billing_address() ) _e( 'N/A', 'woocommerce-delivery-notes' ); else echo apply_filters( 'wcdn_address_billing', $order-&gt;get_formatted_billing_address(), $order ); ?&gt;
                            
                        &lt;/address&gt;
                    &lt;/div&gt;
                    
                    &lt;div class="shipping-address"&gt;                        
                        &lt;h3&gt;&lt;?php _e( 'Shipping Address', 'woocommerce-delivery-notes' ); ?&gt;&lt;/h3&gt;
                        &lt;address&gt;
    
                            &lt;?php if( !$order-&gt;get_formatted_shipping_address() ) _e( 'N/A', 'woocommerce-delivery-notes' ); else echo apply_filters( 'wcdn_address_shipping', $order-&gt;get_formatted_shipping_address(), $order ); ?&gt;
                        
                        &lt;/address&gt;
                    &lt;/div&gt;
                                        
                    &lt;?php do_action( 'wcdn_after_addresses', $order ); ?&gt;
                &lt;/div&gt;&lt;!-- .order-addresses --&gt;




                &lt;div class="order-info"&gt;
                    &lt;h2&gt;&lt;?php wcdn_document_title(); ?&gt;&lt;/h2&gt;


                    &lt;ul class="info-list"&gt;
                        &lt;?php $fields = apply_filters( 'wcdn_order_info_fields', wcdn_get_order_info( $order ), $order ); ?&gt;
                        &lt;?php foreach( $fields as $field ) : ?&gt;
                            &lt;li&gt;
                                &lt;strong&gt;&lt;?php echo apply_filters( 'wcdn_order_info_name', $field['label'], $field ); ?&gt;&lt;/strong&gt;
                                &lt;span&gt;&lt;?php echo apply_filters( 'wcdn_order_info_content', $field['value'], $field ); ?&gt;&lt;/span&gt;
                            &lt;/li&gt;
                        &lt;?php endforeach; ?&gt;
                    &lt;/ul&gt;
                    
                    &lt;?php do_action( 'wcdn_after_info', $order ); ?&gt;
                &lt;/div&gt;&lt;!-- .order-info --&gt;
                
                
                &lt;div class="order-items"&gt;
                    &lt;table&gt;
                        &lt;thead&gt;
                            &lt;tr&gt;
                                &lt;th class="head-name"&gt;&lt;span&gt;&lt;?php _e('Product', 'woocommerce-delivery-notes'); ?&gt;&lt;/span&gt;&lt;/th&gt;
                                &lt;th class="head-item-price"&gt;&lt;span&gt;&lt;?php _e('Price', 'woocommerce-delivery-notes'); ?&gt;&lt;/span&gt;&lt;/th&gt;
                                &lt;th class="head-quantity"&gt;&lt;span&gt;&lt;?php _e('Quantity', 'woocommerce-delivery-notes'); ?&gt;&lt;/span&gt;&lt;/th&gt;
                                &lt;th class="head-price"&gt;&lt;span&gt;&lt;?php _e('Total', 'woocommerce-delivery-notes'); ?&gt;&lt;/span&gt;&lt;/th&gt;
                            &lt;/tr&gt;
                        &lt;/thead&gt;
                        
                        &lt;tbody&gt;
                            &lt;?php if( sizeof( $order-&gt;get_items() ) &gt; 0 ) : ?&gt;
                                &lt;?php foreach( $order-&gt;get_items() as $item ) : ?&gt;
                                    
                                    &lt;?php
                                        $product = apply_filters( 'wcdn_order_item_product', $order-&gt;get_product_from_item( $item ), $item );
                                        $item_meta = new WC_Order_Item_Meta( $item['item_meta'], $product );
                                    ?&gt;
                                    
                                    &lt;tr&gt;
                                        &lt;td class="product-name"&gt;
                                            &lt;?php do_action( 'wcdn_order_item_before', $product, $order ); ?&gt;


                                            &lt;span class="name"&gt;&lt;?php echo apply_filters( 'wcdn_order_item_name', $item['name'], $item ); ?&gt;&lt;/span&gt;


                                            &lt;?php $item_meta-&gt;display(); ?&gt;
                                            
                                            &lt;dl class="extras"&gt;
                                                &lt;?php if( $product &amp;&amp; $product-&gt;exists() &amp;&amp; $product-&gt;is_downloadable() &amp;&amp; $order-&gt;is_download_permitted() ) : ?&gt;
                                                    
                                                    &lt;dt&gt;&lt;?php _e( 'Download:', 'woocommerce-delivery-notes' ); ?&gt;&lt;/dt&gt;
                                                    &lt;dd&gt;&lt;?php printf( __( '%s Files', 'woocommerce-delivery-notes' ), count( $order-&gt;get_item_downloads( $item ) ) ); ?&gt;&lt;/dd&gt;
                                                        
                                                &lt;?php endif; ?&gt;
                                                
                                                &lt;?php 
                                                    $fields = apply_filters( 'wcdn_order_item_fields', array(), $product, $order ); 
                                                    foreach ( $fields as $field ) : 
                                                ?&gt;
                                                
                                                    &lt;dt&gt;&lt;?php echo $field['label']; ?&gt;&lt;/dt&gt;
                                                    &lt;dd&gt;&lt;?php echo $field['value']; ?&gt;&lt;/dd&gt;
                                                        
                                                &lt;?php endforeach; ?&gt;
                                            &lt;/dl&gt;
                                        &lt;/td&gt;
                                        &lt;td class="product-item-price"&gt;
                                            &lt;span&gt;&lt;?php echo wcdn_get_formatted_item_price( $order, $item ); ?&gt;&lt;/span&gt;
                                        &lt;/td&gt;
                                        &lt;td class="product-quantity"&gt;
                                            &lt;span&gt;&lt;?php echo apply_filters( 'wcdn_order_item_quantity', $item['qty'], $item ); ?&gt;&lt;/span&gt;
                                        &lt;/td&gt;
                                        &lt;td class="product-price"&gt;
                                            &lt;span&gt;&lt;?php echo $order-&gt;get_formatted_line_subtotal( $item ); ?&gt;&lt;/span&gt;
                                        &lt;/td&gt;
                                    &lt;/tr&gt;
                                &lt;?php endforeach; ?&gt;
                            &lt;?php endif; ?&gt;
                        &lt;/tbody&gt;
                        
                        &lt;tfoot&gt;                                                    
                            &lt;?php if( $totals = $order-&gt;get_order_item_totals() ) : ?&gt;
                                &lt;?php foreach( $totals as $total ) : ?&gt;
                                &lt;?php $totale = $total['value'];?&gt;
                                &lt;?php endforeach; ?&gt;
                                &lt;?php $totale = explode ('(', $totale);
                                echo $totale[0]?&gt;
                            &lt;?php endif; ?&gt;                                            
                            &lt;?php if( $totals = $order-&gt;get_order_item_totals() ) : ?&gt;
                                &lt;?php foreach( $totals as $total ) : ?&gt;
                                    &lt;tr&gt;
                                        &lt;td class="total-name"&gt;&lt;span&gt;&lt;?php echo $total['label']; ?&gt;&lt;/span&gt;&lt;/td&gt;
                                        &lt;td class="total-item-price"&gt;&lt;/td&gt;
                                        &lt;td class="total-quantity"&gt;&lt;/td&gt;
                                        &lt;td class="total-price"&gt;&lt;span&gt;&lt;?php echo $total['value']; ?&gt;&lt;/span&gt;&lt;/td&gt;
                                    &lt;/tr&gt;
                                &lt;?php endforeach; ?&gt;
                            &lt;?php endif; ?&gt;
                        &lt;/tfoot&gt;
                    &lt;/table&gt;
                                        
                    &lt;?php do_action( 'wcdn_after_items', $order ); ?&gt;
                &lt;/div&gt;&lt;!-- .order-items --&gt;
                
                
                &lt;div class="order-notes"&gt;
                    &lt;?php if( wcdn_has_customer_notes( $order ) ) : ?&gt;
                        &lt;h4&gt;&lt;?php _e( 'Customer Note', 'woocommerce-delivery-notes' ); ?&gt;&lt;/h4&gt;
                        &lt;?php wcdn_customer_notes( $order ); ?&gt;
                    &lt;?php endif; ?&gt;
                    
                    &lt;?php do_action( 'wcdn_after_notes', $order ); ?&gt;
                &lt;/div&gt;&lt;!-- .order-notes --&gt;
                    
                
                &lt;div class="order-thanks"&gt;
                    &lt;?php wcdn_personal_notes(); ?&gt;
                    
                    &lt;?php do_action( 'wcdn_after_thanks', $order ); ?&gt;
                &lt;/div&gt;&lt;!-- .order-thanks --&gt;
                    
                    
                &lt;div class="order-colophon"&gt;
                    &lt;div class="colophon-policies"&gt;
                        &lt;?php wcdn_policies_conditions(); ?&gt;
                    &lt;/div&gt;
                    
                    &lt;div class="colophon-imprint"&gt;
                        &lt;?php wcdn_imprint(); ?&gt;
                    &lt;/div&gt;    
                    
                    &lt;?php do_action( 'wcdn_after_colophon', $order ); ?&gt;
                &lt;/div&gt;&lt;!-- .order-colophon --&gt;
</code></pre>
]]></description><link>https://dev.connect.gt/post/1218452</link><guid isPermaLink="true">https://dev.connect.gt/post/1218452</guid><dc:creator><![CDATA[ottomasi]]></dc:creator><pubDate>Sat, 05 Mar 2016 09:26:25 GMT</pubDate></item><item><title><![CDATA[Reply to Da stringa a float - (float) e floatval non funzionano on Sat, 05 Mar 2016 09:21:53 GMT]]></title><description><![CDATA[<p dir="auto">Grazie Mentelibera!<br />
Purtroppo non è lì il problema.<br />
Tra i tanti tentativi che ho fatto c'era pure quello ma non ha cambiato il risultato inoltre a Bacca001 il codice funziona cosi come l'ho scritto. La stessa cosa dà a me se valorizzo a "mano" la stringa nella prima riga.</p>
]]></description><link>https://dev.connect.gt/post/1218451</link><guid isPermaLink="true">https://dev.connect.gt/post/1218451</guid><dc:creator><![CDATA[ottomasi]]></dc:creator><pubDate>Sat, 05 Mar 2016 09:21:53 GMT</pubDate></item><item><title><![CDATA[Reply to Da stringa a float - (float) e floatval non funzionano on Fri, 04 Mar 2016 22:59:47 GMT]]></title><description><![CDATA[<p dir="auto">Salve <em>ottomasi</em>, penso che il problema sia dovuto alla notazione usata nella definizione decimale perché in PHP riprende il sistema angolassone, quindi usa il punto (".") e non la virgola come da noi come separatore.</p>
<p dir="auto">A mio avviso potrebbe essere utile convertire la virgola con il punto se non fosse possibile cambiare l'impostazione numerica.</p>
<p dir="auto">Provi a fare questa modifica e ci faccia sapere.</p>
]]></description><link>https://dev.connect.gt/post/1218454</link><guid isPermaLink="true">https://dev.connect.gt/post/1218454</guid><dc:creator><![CDATA[mentelibera]]></dc:creator><pubDate>Fri, 04 Mar 2016 22:59:47 GMT</pubDate></item><item><title><![CDATA[Reply to Da stringa a float - (float) e floatval non funzionano on Fri, 04 Mar 2016 22:35:08 GMT]]></title><description><![CDATA[<p dir="auto">Figurati, se hai bisogno ancora chiedi pure <img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=12b9555a9a1" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://dev.connect.gt/post/1218446</link><guid isPermaLink="true">https://dev.connect.gt/post/1218446</guid><dc:creator><![CDATA[bacca001]]></dc:creator><pubDate>Fri, 04 Mar 2016 22:35:08 GMT</pubDate></item><item><title><![CDATA[Reply to Da stringa a float - (float) e floatval non funzionano on Fri, 04 Mar 2016 22:26:35 GMT]]></title><description><![CDATA[<p dir="auto">Ora devo uscire. Ma sei molto gentile! <img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=12b9555a9a1" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://dev.connect.gt/post/1218450</link><guid isPermaLink="true">https://dev.connect.gt/post/1218450</guid><dc:creator><![CDATA[ottomasi]]></dc:creator><pubDate>Fri, 04 Mar 2016 22:26:35 GMT</pubDate></item><item><title><![CDATA[Reply to Da stringa a float - (float) e floatval non funzionano on Fri, 04 Mar 2016 22:21:22 GMT]]></title><description><![CDATA[<p dir="auto">Hai skype? vuoi una mano?</p>
]]></description><link>https://dev.connect.gt/post/1218445</link><guid isPermaLink="true">https://dev.connect.gt/post/1218445</guid><dc:creator><![CDATA[bacca001]]></dc:creator><pubDate>Fri, 04 Mar 2016 22:21:22 GMT</pubDate></item><item><title><![CDATA[Reply to Da stringa a float - (float) e floatval non funzionano on Fri, 04 Mar 2016 22:16:08 GMT]]></title><description><![CDATA[<p dir="auto">La cosa bella è che se aggiungo come prima riga questo:</p>
<p dir="auto">$totale="147,00€ (Include 26,51€ IVA)"</p>
<p dir="auto">Funziona!</p>
<p dir="auto">Come se la stringa che mi restituisce woocommerce (sto modificando un pezzo del pagamento) abbia qualcosa che incasina tutto. Boh!</p>
]]></description><link>https://dev.connect.gt/post/1218449</link><guid isPermaLink="true">https://dev.connect.gt/post/1218449</guid><dc:creator><![CDATA[ottomasi]]></dc:creator><pubDate>Fri, 04 Mar 2016 22:16:08 GMT</pubDate></item><item><title><![CDATA[Reply to Da stringa a float - (float) e floatval non funzionano on Fri, 04 Mar 2016 22:14:08 GMT]]></title><description><![CDATA[<p dir="auto">Mi aspetto il risultato che hai scritto tu.<br />
Il problema è che a me risulta cosi: "floatval=0"</p>
]]></description><link>https://dev.connect.gt/post/1218447</link><guid isPermaLink="true">https://dev.connect.gt/post/1218447</guid><dc:creator><![CDATA[ottomasi]]></dc:creator><pubDate>Fri, 04 Mar 2016 22:14:08 GMT</pubDate></item><item><title><![CDATA[Reply to Da stringa a float - (float) e floatval non funzionano on Fri, 04 Mar 2016 22:10:10 GMT]]></title><description><![CDATA[<p dir="auto">A me questo:</p>
<pre><code class="language-php">&lt;?php
$totale = "147,00&amp;#8364; (Include 26,51&amp;#8364; IVA)";
echo "totale=".$totale;
$totale = explode ('(', $totale);
echo "explode=".$totale[0];
$totale = str_replace('&amp;#8364;','',$totale[0]);
echo "&lt;br&gt;str_replace=".$totale;
$totale = substr($totale,0,-1);
echo "&lt;br&gt;substr=".$totale;
$totale = floatval($totale);
echo "&lt;br&gt;floatval=".$totale;
?&gt;
</code></pre>
<p dir="auto">ritorna così:<br />
totale=147,00€ (Include 26,51€ IVA)explode=147,00€<br />
str_replace=147,00<br />
substr=147,00<br />
floatval=147</p>
<p dir="auto">cosa dovresti aspettarti invece?</p>
]]></description><link>https://dev.connect.gt/post/1218456</link><guid isPermaLink="true">https://dev.connect.gt/post/1218456</guid><dc:creator><![CDATA[bacca001]]></dc:creator><pubDate>Fri, 04 Mar 2016 22:10:10 GMT</pubDate></item><item><title><![CDATA[Reply to Da stringa a float - (float) e floatval non funzionano on Fri, 04 Mar 2016 21:58:20 GMT]]></title><description><![CDATA[<p dir="auto">Non sono certo di aver capito.<br />
Mi serve quel numero come variabile numerica perché poi devo farci dei calcoli.</p>
]]></description><link>https://dev.connect.gt/post/1218444</link><guid isPermaLink="true">https://dev.connect.gt/post/1218444</guid><dc:creator><![CDATA[ottomasi]]></dc:creator><pubDate>Fri, 04 Mar 2016 21:58:20 GMT</pubDate></item><item><title><![CDATA[Reply to Da stringa a float - (float) e floatval non funzionano on Fri, 04 Mar 2016 21:52:15 GMT]]></title><description><![CDATA[<p dir="auto">Cosa dovresti fare, manipolare la stringa?</p>
]]></description><link>https://dev.connect.gt/post/1218455</link><guid isPermaLink="true">https://dev.connect.gt/post/1218455</guid><dc:creator><![CDATA[bacca001]]></dc:creator><pubDate>Fri, 04 Mar 2016 21:52:15 GMT</pubDate></item></channel></rss>